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:
  10. pull_request:
  11. permissions:
  12. contents: read
  13. concurrency:
  14. group: node-${{ github.head_ref || github.run_id }}
  15. cancel-in-progress: true
  16. jobs:
  17. changes:
  18. runs-on: ubuntu-latest-low
  19. outputs:
  20. src: ${{ steps.changes.outputs.src}}
  21. steps:
  22. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  23. id: changes
  24. continue-on-error: true
  25. with:
  26. filters: |
  27. src:
  28. - '.github/workflows/**'
  29. - '**/src/**'
  30. - '**/appinfo/info.xml'
  31. - 'package.json'
  32. - 'package-lock.json'
  33. - 'tsconfig.json'
  34. - '**.js'
  35. - '**.ts'
  36. - '**.vue'
  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: '^9'
  51. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  52. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
  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