node.yml 2.9 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. #
  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/img/**'
  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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
  45. - name: Read package.json node and npm engines version
  46. uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
  47. id: versions
  48. with:
  49. fallbackNode: '^20'
  50. fallbackNpm: '^10'
  51. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  52. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
  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