Skip to content

Commit

Permalink
Add workflow to update Node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Jan 14, 2024
1 parent 4b846ce commit f091656
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

LATEST_LTS_VERSION=$(curl -sL https://nodejs.org/download/release/index.json | jq -r '[.[] | select(.lts != false)] | first | .version | sub("^v"; "")')
for file in Dockerfile*; do
sed -i "s/ENV NODE_VERSION .*/ENV NODE_VERSION $LATEST_LTS_VERSION/g" "$file"
done
sed -i "s/Node.js [0-9]*\.[0-9]*\.[0-9]*/Node.js $LATEST_LTS_VERSION/g" README.md
echo "version=$LATEST_LTS_VERSION" >> $GITHUB_OUTPUT
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build
on:
push:
pull_request:
workflow_dispatch:
jobs:
get-matrix:
Expand Down Expand Up @@ -78,3 +78,15 @@ jobs:
build-args: ${{ matrix.build_args }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Results
needs: [build]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
36 changes: 36 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update

on:
schedule:
- cron: '0 23 */2 * *'
workflow_dispatch:

jobs:
update-node-version:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Update
id: update
run: bash .github/scripts/update.sh

- name: Create update PR
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.TOKEN }}
author: "Node.js GitHub Bot <[email protected]>"
branch: update-branch
branch-suffix: short-commit-hash
base: main
commit-message: "Bump Node.js version to ${{ steps.update.outputs.version }}"
title: "Bump Node.js version to ${{ steps.update.outputs.version }}"
delete-branch: true
- name: Auto approve and merge
if: steps.cpr.outputs.pull-request-operation == 'created'
run: |
gh pr merge -R "${{ github.repository }}" --merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.TOKEN }}

0 comments on commit f091656

Please sign in to comment.