Skip to content

Build and publish Docker images #40

Build and publish Docker images

Build and publish Docker images #40

name: Build and publish Docker images
on:
push:
branches:
- main
paths-ignore:
- legacy/**
pull_request:
paths-ignore:
- legacy/**
schedule:
# Daily rebuild, to pick up upstream Alpine security updates.
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
contents: read
# A run that publishes must never be interrupted: the images share mutable tags,
# so two concurrent runs could push `latest` from two different builds, and a
# cancellation between the two build steps would publish one image and not the
# other. A run that publishes nothing is cancelled when superseded.
concurrency:
group: docker-build-push-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
# The Dockerfile asserts these versions at build time, so the tags are read
# from it rather than repeated here, where they could drift.
- name: Read the advertised versions
id: versions
run: |
set -euo pipefail
python=$(sed -n 's/^ARG PYTHON_VERSION=//p' Dockerfile)
nodejs=$(sed -n 's/^ARG NODEJS_VERSION=//p' Dockerfile)
test -n "${python}" && test -n "${nodejs}"
echo "python=${python}" >> "$GITHUB_OUTPUT"
echo "nodejs=${nodejs}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build filigran/alpine-python-fips
uses: docker/build-push-action@v7
with:
context: .
target: python-fips
platforms: linux/amd64
pull: true
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
filigran/alpine-python-fips:python${{ steps.versions.outputs.python }}
filigran/alpine-python-fips:latest
- name: Build filigran/alpine-python-nodejs-fips
uses: docker/build-push-action@v7
with:
context: .
target: python-nodejs-fips
platforms: linux/amd64
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
filigran/alpine-python-nodejs-fips:python${{ steps.versions.outputs.python }}-nodejs${{ steps.versions.outputs.nodejs }}
filigran/alpine-python-nodejs-fips:latest