Skip to content

Run builds in parallel then reconcile manifests. #13

Run builds in parallel then reconcile manifests.

Run builds in parallel then reconcile manifests. #13

name: Build and push multi-arch images
on:
workflow_dispatch:
inputs:
gitRef:
description: Commit, tag or branch name to deploy
required: true
type: string
default: main
pushToRegistry:
description: Push to Registry. Set to false to test the build without pushing.
required: true
type: boolean
default: false
push:
branches:
- GIFT-multiarch
jobs:
build_and_push_amd64:
name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for AMD64 and push to GHCR
runs-on: ubuntu-22.04
strategy:
matrix:
version: [
{rubyver: ['3', '1', '4'], extra: ''},
{rubyver: ['3', '2', '2'], extra: 'latest'},
]
permissions:
packages: write
steps:
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout from GitHub
uses: actions/[email protected]
with:
ref: ${{ inputs.gitRef || github.ref }}
- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v3
- name: Calculate Image Tags
id: calculate-image-tags
run: |
CREATED_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "createdDate=${CREATED_DATE}" >> $GITHUB_OUTPUT
- name: Generate Base Image Metadata
uses: docker/[email protected]
id: base-image-metadata
with:
flavor: |
latest=${{ matrix.version.extra == 'latest' }}
images: |
ghcr.io/alphagov/govuk-ruby-base
labels: |
org.opencontainers.image.title=govuk-ruby-base
org.opencontainers.image.authors=GOV.UK Platform Engineering
org.opencontainers.image.description=Base Image for GOV.UK Ruby-based Apps
org.opencontainers.image.source=https://github.com/alphagov/govuk-ruby-images
org.opencontainers.image.version=${{ join(matrix.version.rubyver, '.') }}
org.opencontainers.image.created=${{ steps.calculate-image-tags.outputs.createdDate }}
org.opencontainers.image.vendor=GDS
tags: |
type=semver,pattern={{raw}},suffix=-amd64,value=${{ join(matrix.version.rubyver, '.') }}
type=raw,value=latest-amd64,enable=${{ matrix.version.extra == 'latest' }}
type=sha,enable=true,format=long,suffix=-amd64
type=sha,enable=true,priority=100,prefix=sha-,suffix=-amd64,format=short
- name: Generate Builder Image Metadata
uses: docker/[email protected]
id: builder-image-metadata
with:
flavor: |
latest=${{ matrix.version.extra == 'latest' }}
images: |
ghcr.io/alphagov/govuk-ruby-builder
labels: |
org.opencontainers.image.title=govuk-ruby-builder
org.opencontainers.image.authors=GOV.UK Platform Engineering
org.opencontainers.image.description=Builder Image for GOV.UK Ruby-based Apps
org.opencontainers.image.source=https://github.com/alphagov/govuk-ruby-images
org.opencontainers.image.version=${{ join(matrix.version.rubyver, '.') }}
org.opencontainers.image.created=${{ steps.calculate-image-tags.outputs.createdDate }}
org.opencontainers.image.vendor=GDS
tags: |
type=semver,pattern={{raw}},suffix=-amd64,value=${{ join(matrix.version.rubyver, '.') }}
type=raw,value=latest-amd64,enable=${{ matrix.version.extra == 'latest' }}
type=sha,enable=true,format=long,suffix=-amd64
type=sha,enable=true,priority=100,prefix=sha-,suffix=-amd64,format=short
- name: Build Base Image
id: build-base-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
context: .
push: ${{ inputs.pushToRegistry || true }}
platforms: "linux/amd64"
build-args: |
RUBY_MAJOR=${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
RUBY_VERSION=${{ join(matrix.version.rubyver, '.') }}
tags: |
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}
${{ matrix.version.extra }}
- name: Build Builder Image
id: build-builder-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
context: .
push: ${{ inputs.pushToRegistry || true }}
platforms: "linux/amd64"
build-args: |
RUBY_MAJOR=${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
RUBY_VERSION=${{ join(matrix.version.rubyver, '.') }}
OWNER=${{ github.repository_owner }}
tags: |
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}
${{ matrix.version.extra }}
build_and_push_arm64:
name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for ARM64 and push to GHCR
runs-on: ubuntu-22.04
strategy:
matrix:
version: [
{rubyver: ['3', '1', '4'], extra: ''},
{rubyver: ['3', '2', '2'], extra: 'latest'},
]
permissions:
packages: write
steps:
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout from GitHub
uses: actions/[email protected]
with:
ref: ${{ inputs.gitRef || github.ref }}
- name: Set up QEMU (on ARM64 Only)
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v3
- name: Calculate Image Tags
id: calculate-image-tags
run: |
CREATED_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "createdDate=${CREATED_DATE}" >> $GITHUB_OUTPUT
- name: Generate Base Image Metadata
uses: docker/[email protected]
id: base-image-metadata
with:
flavor: |
latest=${{ matrix.version.extra == 'latest' }}
images: |
ghcr.io/alphagov/govuk-ruby-base
labels: |
org.opencontainers.image.title=govuk-ruby-base
org.opencontainers.image.authors=GOV.UK Platform Engineering
org.opencontainers.image.description=Base Image for GOV.UK Ruby-based Apps
org.opencontainers.image.source=https://github.com/alphagov/govuk-ruby-images
org.opencontainers.image.version=${{ join(matrix.version.rubyver, '.') }}
org.opencontainers.image.created=${{ steps.calculate-image-tags.outputs.createdDate }}
org.opencontainers.image.vendor=GDS
tags: |
type=semver,pattern={{raw}},suffix=-amd64,value=${{ join(matrix.version.rubyver, '.') }}
type=sha,enable=true,priority=100,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64,format=short
type=raw,value=latest-amd64,enable=${{ matrix.version.extra == 'latest' }}
- name: Generate Builder Image Metadata
uses: docker/[email protected]
id: builder-image-metadata
with:
flavor: |
latest=${{ matrix.version.extra == 'latest' }}
images: |
ghcr.io/alphagov/govuk-ruby-builder
labels: |
org.opencontainers.image.title=govuk-ruby-builder
org.opencontainers.image.authors=GOV.UK Platform Engineering
org.opencontainers.image.description=Builder Image for GOV.UK Ruby-based Apps
org.opencontainers.image.source=https://github.com/alphagov/govuk-ruby-images
org.opencontainers.image.version=${{ join(matrix.version.rubyver, '.') }}
org.opencontainers.image.created=${{ steps.calculate-image-tags.outputs.createdDate }}
org.opencontainers.image.vendor=GDS
tags: |
type=semver,pattern={{raw}},suffix=-amd64,value=${{ join(matrix.version.rubyver, '.') }}
type=sha,enable=true,priority=100,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64,format=long
type=sha,enable=true,priority=100,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64,format=short
type=raw,value=latest-amd64,enable=${{ matrix.version.extra == 'latest' }}
- name: Build Base Image
id: build-base-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
context: .
push: ${{ inputs.pushToRegistry || true }}
platforms: "linux/arm64"
build-args: |
RUBY_MAJOR=${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
RUBY_VERSION=${{ join(matrix.version.rubyver, '.') }}
tags: |
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}
${{ matrix.version.extra }}
- name: Build Builder Image
id: build-builder-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
context: .
push: ${{ inputs.pushToRegistry || true }}
platforms: "linux/arm64"
build-args: |
RUBY_MAJOR=${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
RUBY_VERSION=${{ join(matrix.version.rubyver, '.') }}
OWNER=${{ github.repository_owner }}
tags: |
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ matrix.version.rubyver[0] }}.${{ matrix.version.rubyver[1] }}
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}
${{ matrix.version.extra }}
create_docker_manifests:
name: Create Docker Manifests for Ruby ${{ join(matrix.version.rubyver, '.') }} Images
needs:
- build_and_push_amd64
- build_and_push_arm64
runs-on: ubuntu-22.04
strategy:
matrix:
version: [
{rubyver: ['3', '1', '4'], extra: ''},
{rubyver: ['3', '2', '2'], extra: 'latest'},
]
permissions:
packages: write
steps:
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout from GitHub
uses: actions/[email protected]
with:
ref: ${{ inputs.gitRef || github.ref }}
- name: Create SHA manifest and push for Ruby Base Images
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }} \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}
- name: Create SHA manifest and push for Ruby Builder Images
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }} \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}
- name: Create Ruby Versioned manifest and push for Ruby Base Images
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }} \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:${{ join(matrix.version.rubyver, '.') }}
- name: Create Ruby Versioned manifest and push for Ruby Builder Images
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }} \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}-${{ github.sha }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:${{ join(matrix.version.rubyver, '.') }}
- name: Create Latest manifest and push for Ruby Base Images
if: ${{ matrix.version.extra == 'latest' }}
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:latest \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:latest-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:latest-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-base:latest
- name: Create Latest manifest and push for Ruby Builder Images
if: ${{ matrix.version.extra == 'latest' }}
run: |
docker manifest create \
ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:latest \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:latest-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:latest-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/govuk-ruby-builder:latest