Update for 21.6.2 (#208) #522
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "Dockerfile" | |
- "build.sh" | |
- ".github/workflows/dockerimage.yml" | |
pull_request: | |
env: | |
IMAGE_NAME: node-minimal | |
NODE_VERSION: "21.6.2" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
- 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 Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.IMAGE_NAME }}-${{ env.NODE_VERSION }} | |
- name: Test Image | |
run: docker run --rm ${{ env.IMAGE_NAME }}-${{ env.NODE_VERSION }} -e "console.log('Hello from Node.js ' + process.version)" | |
- name: Upload Node | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }}-${{ env.NODE_VERSION }} | |
path: node | |
push: | |
# Ensure test job passes before pushing image. | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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: Download built node | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }}-${{ env.NODE_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: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
provenance: mode=max | |
sbom: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |