From e676d6fe73810cd1a2452957098ab47ea37c028c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 30 Aug 2023 19:37:16 +0200 Subject: [PATCH] ci: Add workflow to update node dist files on main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl fix: Check build changes Signed-off-by: Julius Härtl fix: use CYPRESS_INSTALL_BINARY Signed-off-by: Julius Härtl fix: ref for push Signed-off-by: Julius Härtl ci(node): Block merge if js/ was changed Signed-off-by: Julius Härtl tmp: remove test branch to see if node check works Signed-off-by: Julius Härtl --- .github/workflows/node-dist-unchanged.yml | 26 ++++++++++ .github/workflows/node.yml | 11 ---- .github/workflows/update-node-dist.yml | 61 +++++++++++++++++++++++ .gitignore | 3 ++ 4 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/node-dist-unchanged.yml create mode 100644 .github/workflows/update-node-dist.yml diff --git a/.github/workflows/node-dist-unchanged.yml b/.github/workflows/node-dist-unchanged.yml new file mode 100644 index 00000000000..1f24df7c202 --- /dev/null +++ b/.github/workflows/node-dist-unchanged.yml @@ -0,0 +1,26 @@ +name: Check node dist files + +on: + pull_request: + + +jobs: + changed_files: + runs-on: ubuntu-latest + name: Check node dist files + permissions: + pull-requests: read + + steps: + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v39 + with: + files: js/** + + - name: Run step if any file(s) in the docs folder change + if: steps.changed-files-specific.outputs.any_changed == 'true' + run: | + echo "One or more files in the js folder has changed. Do NOT commit files in there as they will be generated automatically once a pull request is merged" + echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}" + exit 1 diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 07ac7254fd9..c69f6a3ba21 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -66,14 +66,3 @@ jobs: webpackStatsFile: ./webpack-stats.json key: ${{ secrets.RELATIVE_CI_KEY }} token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check webpack build changes - run: | - bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)" - - - name: Show changes on failure - if: failure() - run: | - git status - git --no-pager diff - exit 1 # make it red to grab attention diff --git a/.github/workflows/update-node-dist.yml b/.github/workflows/update-node-dist.yml new file mode 100644 index 00000000000..6358f7e37ca --- /dev/null +++ b/.github/workflows/update-node-dist.yml @@ -0,0 +1,61 @@ +name: Update Node dist + +on: + workflow_dispatch: + push: + branches: + # implemented since 28, once branched off, add your stable branch here + - main + # - ci/node-dist-workflow + # - stable28 + +concurrency: + group: update-node-dist-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + update-node-dist: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.1 + id: versions + with: + fallbackNode: '^20' + fallbackNpm: '^9' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3 + 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: Setup git + run: | + git config --local user.email "nextcloud-command@users.noreply.github.com" + git config --local user.name "nextcloud-command" + - name: Install dependencies & build + env: + CYPRESS_INSTALL_BINARY: 0 + run: | + npm ci + npm run build --if-present + + - name: Check webpack build changes + id: changes + continue-on-error: true + run: | + bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)" + + - name: Add and commit + if: steps.changes.outcome == 'failure' + run: | + git add --force js/ + git commit --signoff -m 'chore(assets): recompile assets' + git push origin ${{ github.head_ref }} diff --git a/.gitignore b/.gitignore index 49b07b230c4..cd94b4ea5d9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ cypress/downloads/ /tests/.phpunit.result.cache dist/ webpack-stats.json + +# js folder, to be updated wth --force +/js