Skip to content

Update Image

Update Image #361

name: Update Image
on:
schedule:
- cron: '30 0,6 * * *'
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@v4
- name: Get NODE_VERSION
id: get_version
run: echo "NODE_VERSION=$(./check-missing-versions.sh | tail -1)" >> $GITHUB_OUTPUT
- name: Show NODE_VERSION
run: echo ${{ steps.get_version.outputs.NODE_VERSION }}
build_push:
needs: check_version
runs-on: ubuntu-latest
if: needs.check_version.outputs.NODE_VERSION
env:
NODE_VERSION: ${{needs.check_version.outputs.NODE_VERSION}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/[email protected]
- name: Show NODE_VERSION
run: echo $NODE_VERION
- name: Set MAJOR_VERSION
run: echo "MAJOR_VERSION=$(echo $NODE_VERSION | cut -d'.' -f 1)" >> $GITHUB_ENV
- name: Show MAJOR_VERSION
run: echo $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@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: .
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@v5
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: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push Image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
provenance: mode=max
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}