ci: Automate base image + sbom + attestation (#17248)

This commit is contained in:
shortstacked
2025-07-16 11:35:33 +01:00
committed by GitHub
parent cca1c2d810
commit a417159602
2 changed files with 31 additions and 26 deletions

View File

@@ -1,55 +1,59 @@
name: Docker Base Image CI name: Docker Base Image CI
on: on:
workflow_dispatch: push:
inputs: branches:
node_version: - master
description: 'Node.js version to build this image with.' paths:
type: choice - 'docker/images/n8n-base/Dockerfile'
required: true pull_request:
default: '20' paths:
options: - 'docker/images/n8n-base/Dockerfile'
- '20'
- '22'
- '24'
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
node_version: ['20', '22', '24']
steps: steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0 uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 if: github.event_name == 'push'
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build - name: Build and push
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0 uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
env:
DOCKER_BUILD_SUMMARY: false
with: with:
context: . context: .
file: ./docker/images/n8n-base/Dockerfile file: ./docker/images/n8n-base/Dockerfile
build-args: | build-args: |
NODE_VERSION=${{github.event.inputs.node_version}} NODE_VERSION=${{ matrix.node_version }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
provenance: false provenance: ${{ github.event_name == 'push' }}
push: true sbom: ${{ github.event_name == 'push' }}
push: ${{ github.event_name == 'push' }}
tags: | tags: |
${{ secrets.DOCKER_USERNAME }}/base:${{ github.event.inputs.node_version }} ${{ secrets.DOCKER_USERNAME }}/base:${{ matrix.node_version }}-${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/base:${{ github.event.inputs.node_version }} ${{ secrets.DOCKER_USERNAME }}/base:${{ matrix.node_version }}
ghcr.io/${{ github.repository_owner }}/base:${{ matrix.node_version }}-${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/base:${{ matrix.node_version }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -292,7 +292,8 @@ jobs:
N8N_VERSION=${{ needs.determine-build-context.outputs.n8n_version }} N8N_VERSION=${{ needs.determine-build-context.outputs.n8n_version }}
N8N_RELEASE_TYPE=${{ needs.determine-build-context.outputs.release_type }} N8N_RELEASE_TYPE=${{ needs.determine-build-context.outputs.release_type }}
platforms: ${{ matrix.docker_platform }} platforms: ${{ matrix.docker_platform }}
provenance: false provenance: true
sbom: true
push: ${{ needs.determine-build-context.outputs.push_enabled == 'true' }} push: ${{ needs.determine-build-context.outputs.push_enabled == 'true' }}
tags: ${{ steps.determine-tags.outputs.tags }} tags: ${{ steps.determine-tags.outputs.tags }}