Skip to content

Build Docker Images #1238

Build Docker Images

Build Docker Images #1238

Workflow file for this run

name: Build Docker Images
on:
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
force:
description: "Force update of all images"
required: false
default: "false"
defaults:
run:
shell: bash
env:
PLATFORMS: linux/arm/v6,linux/arm/v7,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/386
jobs:
build-docker:
name: Build and push Images
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- tag: nginxdemos/hello:latest,nginxdemos/hello:0.4
context: nginx-hello
- tag: nginxdemos/hello:plain-text,nginxdemos/hello:0.4-plain-text
context: nginx-hello
file: nginx-hello/DockerfilePlainText
- tag: nginxdemos/nginx-hello:latest,nginxdemos/nginx-hello:0.3
context: nginx-hello-nonroot/html-version
- tag: nginxdemos/nginx-hello:plain-text,nginxdemos/nginx-hello:0.3-plain-text
context: nginx-hello-nonroot/plain-text-version
steps:
- name: Get variables
id: variables
run: |
image=$(cut -d"," -f1 <<< "${{ matrix.tag }}")
echo "image=${image}" >> $GITHUB_OUTPUT
- name: Check if update needed for ${{ steps.variables.outputs.image }}
id: update
uses: lucacome/docker-image-update-checker@v2
with:
base-image: library/nginx:mainline-alpine
image: ${{ steps.variables.outputs.image }}
- name: Checkout
uses: actions/checkout@v4
if: ${{ steps.update.outputs.needs-updating == 'true' || inputs.force == 'true' }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm/v6,arm,arm64,amd64,ppc64le,s390x,386
if: ${{ steps.update.outputs.needs-updating == 'true' || inputs.force == 'true' }}
- name: Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.update.outputs.needs-updating == 'true' || inputs.force == 'true' }}
- name: DockerHub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ steps.update.outputs.needs-updating == 'true' || inputs.force == 'true' }}
- name: Push to Dockerhub for nginx-hello
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
tags: ${{ matrix.tag }}
platforms: ${{ env.PLATFORMS }}
push: true
provenance: true
sbom: true
if: ${{ steps.update.outputs.needs-updating == 'true' || inputs.force == 'true' }}