1
0

node.yml 2.9 KB

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