mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add github action to auto-update docker repo version on release publish
This commit is contained in:
parent
ae1ca85924
commit
2b5a976f35
29
.github/scripts/update-node-red-docker.js
vendored
Normal file
29
.github/scripts/update-node-red-docker.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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 currentVersion = require("../../../node-red-docker/package.json").version;
|
||||||
|
|
||||||
|
console.log(`Update from ${currentVersion} to ${newVersion}`)
|
||||||
|
|
||||||
|
updateFile(__dirname+"/../../../node-red-docker/package.json", currentVersion, newVersion);
|
||||||
|
updateFile(__dirname+"/../../../node-red-docker/docker-custom/package.json", currentVersion, newVersion);
|
||||||
|
updateFile(__dirname+"/../../../node-red-docker/README.md", currentVersion, newVersion);
|
||||||
|
|
||||||
|
console.log(`::set-env name=newVersion::${newVersion}`);
|
||||||
|
|
||||||
|
function updateFile(path,from,to) {
|
||||||
|
let contents = fs.readFileSync(path,"utf8");
|
||||||
|
contents = contents.replace(new RegExp(from.replace(/\./g,"\\."),"g"), to);
|
||||||
|
fs.writeFileSync(path, contents);
|
||||||
|
}
|
37
.github/workflows/build.yml
vendored
Normal file
37
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: PublishDockerImage
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate:
|
||||||
|
name: 'Update node-red-docker image'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out node-red repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: 'node-red'
|
||||||
|
- name: Check out node-red-docker repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: 'node-red/node-red-docker'
|
||||||
|
path: 'node-red-docker'
|
||||||
|
- 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
|
||||||
|
uses: peter-evans/create-pull-request@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.NR_REPO_TOKEN }}
|
||||||
|
committer: GitHub <noreply@github.com>
|
||||||
|
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
||||||
|
path: 'node-red-docker'
|
||||||
|
title: '[TEST] Update to Node-RED ${{ env.newVersion }} release'
|
||||||
|
body: |
|
||||||
|
Updates the Node-RED Docker repo for the ${{ env.newVersion }} release.
|
||||||
|
|
||||||
|
This PR was auto-generated by a GitHub Action. Any questions, speak to @knolleary
|
Loading…
Reference in New Issue
Block a user