1
0

node.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # This workflow is provided via the organization template repository
  2. #
  3. # https://github.com/nextcloud/.github
  4. # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
  5. name: Node
  6. on:
  7. pull_request:
  8. permissions:
  9. contents: read
  10. concurrency:
  11. group: node-${{ github.head_ref || github.run_id }}
  12. cancel-in-progress: true
  13. jobs:
  14. changes:
  15. runs-on: ubuntu-latest-low
  16. outputs:
  17. src: ${{ steps.changes.outputs.src}}
  18. steps:
  19. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  20. id: changes
  21. continue-on-error: true
  22. with:
  23. filters: |
  24. src:
  25. - '.github/workflows/**'
  26. - '**/src/**'
  27. - '**/appinfo/info.xml'
  28. - 'package.json'
  29. - 'package-lock.json'
  30. - 'tsconfig.json'
  31. - '**.js'
  32. - '**.ts'
  33. - '**.vue'
  34. - 'core/css/*'
  35. - 'core/img/**'
  36. - 'version.php'
  37. build:
  38. runs-on: ubuntu-latest
  39. needs: changes
  40. if: needs.changes.outputs.src != 'false'
  41. name: NPM build
  42. steps:
  43. - name: Checkout
  44. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  45. - name: Read package.json node and npm engines version
  46. uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
  47. id: versions
  48. with:
  49. fallbackNode: '^20'
  50. fallbackNpm: '^9'
  51. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  52. uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
  53. with:
  54. node-version: ${{ steps.versions.outputs.nodeVersion }}
  55. - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
  56. run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
  57. - name: Install dependencies & build
  58. env:
  59. CYPRESS_INSTALL_BINARY: 0
  60. PUPPETEER_SKIP_DOWNLOAD: true
  61. run: |
  62. npm ci
  63. npm run build --if-present
  64. - name: Check webpack build changes
  65. run: |
  66. bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
  67. - name: Show changes on failure
  68. if: failure()
  69. run: |
  70. git status
  71. git --no-pager diff
  72. exit 1 # make it red to grab attention
  73. summary:
  74. permissions:
  75. contents: none
  76. runs-on: ubuntu-latest-low
  77. needs: [changes, build]
  78. if: always()
  79. # This is the summary, we just avoid to rename it so that branch protection rules still match
  80. name: node
  81. steps:
  82. - name: Summary status
  83. run: if ${{ needs.changes.outputs.src != 'false' && needs.build.result != 'success' }}; then exit 1; fi