Skip to content

Update Image

Update Image #677

name: Update Image
on:
schedule:
- cron: '30 0 * * *'
workflow_dispatch:
inputs:
node_version:
description: 'Node.js version to build (e.g., 20.10.0). Leave empty to auto-detect latest.'
required: false
type: string
env:
IMAGE_NAME: node-minimal
jobs:
check_version:
runs-on: ubuntu-latest
outputs:
NODE_VERSION: ${{ steps.get_version.outputs.NODE_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Validate and Get NODE_VERSION
id: get_version
run: |
if [[ -n "${{ github.event.inputs.node_version }}" ]]; then
INPUT_VERSION="${{ github.event.inputs.node_version }}"
if ! [[ $INPUT_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format '$INPUT_VERSION'. Expected format: X.Y.Z (e.g., 20.10.0)" >&2
exit 1
fi
NODE_VERSION="$INPUT_VERSION"
else
NODE_VERSION=$(./check-missing-versions.sh | tail -1)
fi
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_OUTPUT
if [[ -n "$NODE_VERSION" ]]; then
echo "Building Node.js version: $NODE_VERSION"
else
echo "No new Node.js versions to build"
fi
build_push:
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
platform:
- amd64
- arm64
exclude:
- os: ubuntu-24.04
platform: arm64
- os: ubuntu-24.04-arm
platform: amd64
needs: check_version
runs-on: ${{ matrix.os }}
if: needs.check_version.outputs.NODE_VERSION
env:
NODE_VERSION: ${{needs.check_version.outputs.NODE_VERSION}}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.22
with:
key: ${{ matrix.os }}-${{ matrix.platform }}
max-size: 10G
- name: Configure ccache
run: |
ccache --set-config=sloppiness=time_macros,locale,include_file_ctime,include_file_mtime
ccache --set-config=hash_dir=false
ccache -p
- name: Set and Display Versions
run: |
MAJOR_VERSION=$(echo $NODE_VERSION | cut -d'.' -f 1)
echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
echo "Building Node.js version: $NODE_VERSION (major: $MAJOR_VERSION)"
- name: Build Node
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
which gcc
./build.sh -n $NODE_VERSION
ccache -s
cp node-v$NODE_VERSION/out/Release/node node
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build
uses: docker/build-push-action@v7
env:
DOCKER_BUILD_SUMMARY: false
with:
context: .
platforms: linux/${{ matrix.platform }}
load: true
tags: ${{ env.IMAGE_NAME }}-${{ needs.check_version.outputs.NODE_VERSION }}
- name: Test Image
run: docker run --rm ${{ env.IMAGE_NAME }}-${{ needs.check_version.outputs.NODE_VERSION }} -e "console.log('Hello from Node.js ' + process.version)"
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
flavor: latest=true
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}, ghcr.io/chorrell/${{ env.IMAGE_NAME }}
tags: |
${{ env.NODE_VERSION }}
${{ env.MAJOR_VERSION }}
current
- name: Build and push Image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/${{ matrix.platform }}
push: true
provenance: mode=max
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}