2021-07-22 13:06:17 +02: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
2020-02-03 08:32:10 +01:00
name : Node
on :
pull_request :
push :
branches :
2022-03-06 19:04:42 +01:00
- main
2020-02-03 08:32:10 +01:00
- master
- stable*
2022-08-03 15:23:20 +02:00
permissions :
contents : read
2020-02-03 08:32:10 +01:00
jobs :
build :
runs-on : ubuntu-latest
2021-07-22 13:06:17 +02:00
name : node
2020-02-03 08:32:10 +01:00
steps :
2021-07-22 13:06:17 +02:00
- name : Checkout
2022-03-06 19:04:42 +01:00
uses : actions/checkout@v3
2020-02-07 16:56:35 +01:00
2021-07-22 13:06:17 +02:00
- name : Read package.json node and npm engines version
2022-03-06 19:04:42 +01:00
uses : skjnldsv/read-package-engines-version-actions@v1.2
2021-07-22 13:06:17 +02:00
id : versions
with :
fallbackNode : '^12'
fallbackNpm : '^6'
2020-12-29 08:18:29 +01:00
2021-07-22 13:06:17 +02:00
- name : Set up node ${{ steps.versions.outputs.nodeVersion }}
2022-03-06 19:04:42 +01:00
uses : actions/setup-node@v3
2020-02-22 20:32:26 +01:00
with :
2021-07-22 13:06:17 +02:00
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
2020-02-22 20:32:26 +01:00
run : |
npm ci
2021-07-22 13:06:17 +02:00
npm run build --if-present
- name : Check webpack build changes
run : |
2022-08-03 15:23:20 +02:00
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
2021-07-22 13:06:17 +02:00
- name : Show changes on failure
if : failure()
run : |
git status
git --no-pager diff
2022-08-03 15:23:20 +02:00
exit 1 # make it red to grab attention