1
0

node.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. build:
  35. runs-on: ubuntu-latest
  36. needs: changes
  37. if: needs.changes.outputs.src != 'false'
  38. name: NPM build
  39. steps:
  40. - name: Checkout
  41. uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v3.6.0
  42. - name: Read package.json node and npm engines version
  43. uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
  44. id: versions
  45. with:
  46. fallbackNode: '^20'
  47. fallbackNpm: '^9'
  48. - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
  49. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
  50. with:
  51. node-version: ${{ steps.versions.outputs.nodeVersion }}
  52. - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
  53. run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
  54. - name: Install dependencies & build
  55. env:
  56. CYPRESS_INSTALL_BINARY: 0
  57. PUPPETEER_SKIP_DOWNLOAD: true
  58. run: |
  59. npm ci
  60. npm run build --if-present
  61. - name: Check webpack build changes
  62. run: |
  63. bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
  64. - name: Show changes on failure
  65. if: failure()
  66. run: |
  67. git status
  68. git --no-pager diff
  69. exit 1 # make it red to grab attention
  70. summary:
  71. permissions:
  72. contents: none
  73. runs-on: ubuntu-latest-low
  74. needs: [changes, build]
  75. if: always()
  76. # This is the summary, we just avoid to rename it so that branch protection rules still match
  77. name: node
  78. steps:
  79. - name: Summary status
  80. run: if ${{ needs.changes.outputs.src != 'false' && needs.build.result != 'success' }}; then exit 1; fi