Skip to content

Check Latest Node

Check Latest Node #3

name: Check Latest Node
on:
schedule:
- cron: '0 0 * * *' # Run every day at midnight
workflow_dispatch:
jobs:
check:
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [18, 20, 22]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compare versions
id: compare
run: |
# get the latest Node.js version with major version matching the matrix node version
LATEST_VERSION=$(curl -s https://nodejs.org/dist/latest-v${{ matrix.node-version }}.x/ | grep -oP 'node-v\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
echo "Latest Node.js ${{ matrix.node-version }} version is: $LATEST_VERSION"
# get the latest patch version
PATCH_VERSION=$(ls patches/node.v${{ matrix.node-version }}.*.patch | grep -oP 'node.v\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
echo "Latest patch version for Node.js ${{ matrix.node-version }} is: $PATCH_VERSION"
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "patch_version=$PATCH_VERSION" >> $GITHUB_OUTPUT
# compare the latest patch version with the latest Node.js version
if [ "$PATCH_VERSION" != "$LATEST_VERSION" ]; then
echo "Patch for Node.js ${{ matrix.node-version }} is outdated"
# set the output variable to true
echo "outdated=true" >> $GITHUB_OUTPUT
fi
- name: Create new patch
uses: ./.github/workflows/patch-node.yml
with:
nodeVersion: ${{ steps.compare.outputs.latest_version }}
patchFile: ${{ steps.compare.outputs.patch_version }}