From 62c01b59b2e655bf07f363983abc3a09a8bdfcbe Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 10 Jul 2020 21:46:00 +0100 Subject: [PATCH] Extend release action to update website --- .github/scripts/update-node-red-website.js | 18 ++++++++++++++++++ .github/workflows/build.yml | 22 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/update-node-red-website.js diff --git a/.github/scripts/update-node-red-website.js b/.github/scripts/update-node-red-website.js new file mode 100644 index 000000000..cc40c2996 --- /dev/null +++ b/.github/scripts/update-node-red-website.js @@ -0,0 +1,18 @@ +const fs = require("fs"); + +const newVersion = require("../../package.json").version; + +if (process.env.GITHUB_REF !== "refs/tags/"+newVersion) { + console.log(`GITHUB_REF doesn't match the package.json version: ${process.env.GITHUB_REF} !== ${newVersion}`); + process.exit(0); +} + +if (!/^\d+\.\d+\.\d+$/.test(newVersion)) { + console.log(`Not updating for a non-stable release - ${newVersion}`); + process.exit(0); +} + +const path = __dirname+"/../../../node-red.github.io/index.html"; +let contents = fs.readFileSync(path, "utf8"); +contents = contents.replace(/v\d+\.\d+\.\d+<\/span>/, `v${newVersion}<\/span>` ); +fs.writeFileSync(path, contents); \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 356d8d71f..43b0137c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,16 @@ jobs: with: repository: 'node-red/node-red-docker' path: 'node-red-docker' + - name: Check out node-red.github.io repository + uses: actions/checkout@v2 + with: + repository: 'node-red/node-red.github.io' + path: 'node-red.github.io' - uses: actions/setup-node@v1 with: node-version: '12' - run: node ./node-red/.github/scripts/update-node-red-docker.js - id: updateFiles - - name: Create Pull Request + - name: Create Docker Pull Request uses: peter-evans/create-pull-request@v2 with: token: ${{ secrets.NR_REPO_TOKEN }} @@ -37,4 +41,18 @@ jobs: Once this is merged, you will need to create a new release with the tag `v${{ env.newVersion }}`. + This PR was auto-generated by a GitHub Action. Any questions, speak to @knolleary + - run: node ./node-red/.github/scripts/update-node-red-website.js + - name: Create Website Pull Request + uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.NR_REPO_TOKEN }} + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + path: 'node-red.github.io' + commit-message: 'Bump to ${{ env.newVersion }}' + title: '🚀 Update to Node-RED ${{ env.newVersion }} release' + body: | + Updates the Node-RED Website repo for the ${{ env.newVersion }} release. + This PR was auto-generated by a GitHub Action. Any questions, speak to @knolleary