2022-04-15 17:37:40 +00:00
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
name : Node
on :
pull_request :
2023-01-16 16:10:56 +00:00
paths :
- '.github/workflows/**'
- 'src/**'
- 'appinfo/info.xml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- '**.js'
- '**.ts'
- '**.vue'
2022-04-15 17:37:40 +00:00
push :
branches :
- main
- master
- stable*
2022-06-11 16:37:40 +00:00
permissions :
contents : read
2023-01-16 16:10:56 +00:00
concurrency :
group : node-${{ github.head_ref || github.run_id }}
cancel-in-progress : true
2022-04-15 17:37:40 +00:00
jobs :
build :
runs-on : ubuntu-latest
name : node
steps :
- name : Checkout
2023-06-01 16:12:30 +00:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-04-15 17:37:40 +00:00
- name : Read package.json node and npm engines version
2023-06-01 16:12:30 +00:00
uses : skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
2022-04-15 17:37:40 +00:00
id : versions
with :
2023-01-16 16:10:56 +00:00
fallbackNode : '^16'
fallbackNpm : '^7'
2022-04-15 17:37:40 +00:00
- name : Set up node ${{ steps.versions.outputs.nodeVersion }}
2023-06-01 16:12:30 +00:00
uses : actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
2022-04-15 17:37:40 +00:00
with :
node-version : ${{ steps.versions.outputs.nodeVersion }}
- name : Set up npm ${{ steps.versions.outputs.npmVersion }}
run : npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name : Install dependencies & build
run : |
npm ci
npm run build --if-present
2022-06-11 16:37:40 +00:00
- name : Check webpack build changes
run : |
2023-01-16 16:10:56 +00:00
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
2022-06-11 16:37:40 +00:00
- name : Show changes on failure
if : failure()
run : |
git status
git --no-pager diff
2023-01-16 16:10:56 +00:00
exit 1 # make it red to grab attention