Skip to content

Commit 62c01b5

Browse files
committed
Extend release action to update website
1 parent 43db182 commit 62c01b5

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require("fs");
2+
3+
const newVersion = require("../../package.json").version;
4+
5+
if (process.env.GITHUB_REF !== "refs/tags/"+newVersion) {
6+
console.log(`GITHUB_REF doesn't match the package.json version: ${process.env.GITHUB_REF} !== ${newVersion}`);
7+
process.exit(0);
8+
}
9+
10+
if (!/^\d+\.\d+\.\d+$/.test(newVersion)) {
11+
console.log(`Not updating for a non-stable release - ${newVersion}`);
12+
process.exit(0);
13+
}
14+
15+
const path = __dirname+"/../../../node-red.github.io/index.html";
16+
let contents = fs.readFileSync(path, "utf8");
17+
contents = contents.replace(/<span class="node-red-latest-version">v\d+\.\d+\.\d+<\/span>/, `<span class="node-red-latest-version">v${newVersion}<\/span>` );
18+
fs.writeFileSync(path, contents);

.github/workflows/build.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ jobs:
1818
with:
1919
repository: 'node-red/node-red-docker'
2020
path: 'node-red-docker'
21+
- name: Check out node-red.github.io repository
22+
uses: actions/checkout@v2
23+
with:
24+
repository: 'node-red/node-red.github.io'
25+
path: 'node-red.github.io'
2126
- uses: actions/setup-node@v1
2227
with:
2328
node-version: '12'
2429
- run: node ./node-red/.github/scripts/update-node-red-docker.js
25-
id: updateFiles
26-
- name: Create Pull Request
30+
- name: Create Docker Pull Request
2731
uses: peter-evans/create-pull-request@v2
2832
with:
2933
token: ${{ secrets.NR_REPO_TOKEN }}
@@ -37,4 +41,18 @@ jobs:
3741
3842
Once this is merged, you will need to create a new release with the tag `v${{ env.newVersion }}`.
3943
44+
This PR was auto-generated by a GitHub Action. Any questions, speak to @knolleary
45+
- run: node ./node-red/.github/scripts/update-node-red-website.js
46+
- name: Create Website Pull Request
47+
uses: peter-evans/create-pull-request@v2
48+
with:
49+
token: ${{ secrets.NR_REPO_TOKEN }}
50+
committer: GitHub <noreply@github.com>
51+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
52+
path: 'node-red.github.io'
53+
commit-message: 'Bump to ${{ env.newVersion }}'
54+
title: '🚀 Update to Node-RED ${{ env.newVersion }} release'
55+
body: |
56+
Updates the Node-RED Website repo for the ${{ env.newVersion }} release.
57+
4058
This PR was auto-generated by a GitHub Action. Any questions, speak to @knolleary

0 commit comments

Comments
 (0)