Skip to content

Commit

Permalink
Tidy up build-multiarch workflow a little.
Browse files Browse the repository at this point in the history
Just a bunch of small things:

- Remove deleted branch from triggers.
- Pick a start minute at random that's not too close to the hour (just
  to be nice and not bunch up with other people's jobs).
- Move the build matrix config file out of the hidden .github directory,
  so nobody else has to waste time looking for it.
- Just specify ubuntu-latest. We'd rather the build breaks because
  something needs updating to work with the latest supported OS (likely
  easy to fix) rather than it breaks because it got left on a pinned
  version until it went out of support (likely more effort to fix).
- Remove `name` fields where they don't add anything beyond what's
  already in the `id` field.
- Remove `id` fields where they're unused _and_ don't add any info
  beyond what's in the `uses` field.
- Turn off logspew on `checkout` actions. (It's annoying this isn't the
  default, but hey.)
- Clean up some spurious whitespace.
  • Loading branch information
sengi committed Feb 5, 2024
1 parent e4e1279 commit 330b7ae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 46 deletions.
81 changes: 35 additions & 46 deletions .github/workflows/build-multiarch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ on:
push:
branches:
- main
- dj-maisy/test_shared_matrix
schedule:
- cron: '0 3 * * *'
- cron: '34 3 * * *'

jobs:
configure_builds:
name: Configure Build Settings (from config.json)
runs-on: ubuntu-22.04
name: Read configuration from build-matrix.json
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set Matrix Data
id: set-matrix
run: echo "matrix=$(jq -c . < .github/config.json)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
show-progress: false
- id: set-matrix
run: echo "matrix=$(jq -c . < build-matrix.json)" >> $GITHUB_OUTPUT

build_and_push_amd64:
name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for AMD64 and push to GHCR
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
needs: configure_builds
strategy:
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}}
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }}
permissions:
packages: write
steps:
Expand All @@ -49,21 +48,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout from GitHub
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: ${{ inputs.gitRef || github.ref }}

- name: Set up Docker BuildX
id: buildx
uses: docker/setup-buildx-action@v3
show-progress: false

- uses: docker/setup-buildx-action@v3

- name: Calculate Image Tags
id: 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/metadata-action@v5
id: base-image-metadata
Expand Down Expand Up @@ -108,8 +104,7 @@ jobs:
type=sha,enable=true,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64,format=short
type=sha,enable=true,priority=100,format=long,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-amd64
- name: Build Base Image
id: build-base-image
- id: build-base-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
Expand All @@ -124,8 +119,7 @@ jobs:
tags: ${{ steps.base-image-metadata.outputs.tags }}
labels: ${{ steps.base-image-metadata.outputs.labels }}

- name: Build Builder Image
id: build-builder-image
- id: build-builder-image
uses: docker/build-push-action@v5
with:
file: builder.Dockerfile
Expand All @@ -143,10 +137,10 @@ jobs:

build_and_push_arm64:
name: Build ruby_${{ join(matrix.version.rubyver, '.') }} for ARM64 and push to GHCR
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
needs: configure_builds
strategy:
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}}
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }}
permissions:
packages: write
steps:
Expand All @@ -157,26 +151,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout from GitHub
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: ${{ inputs.gitRef || github.ref }}
show-progress: false

- name: Set up QEMU (on ARM64 Only)
- name: Set up QEMU for ARM64 build
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
- uses: docker/setup-buildx-action@v3

- 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/metadata-action@v5
id: base-image-metadata
Expand Down Expand Up @@ -221,8 +212,7 @@ jobs:
type=sha,enable=true,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-arm64,format=short
type=sha,enable=true,priority=100,prefix=${{ join(matrix.version.rubyver, '.') }}-,suffix=-arm64,format=long
- name: Build Base Image
id: build-base-image
- id: build-base-image
uses: docker/build-push-action@v5
with:
file: base.Dockerfile
Expand All @@ -237,8 +227,7 @@ jobs:
tags: ${{ steps.base-image-metadata.outputs.tags }}
labels: ${{ steps.base-image-metadata.outputs.labels }}

- name: Build Builder Image
id: build-builder-image
- id: build-builder-image
uses: docker/build-push-action@v5
with:
file: builder.Dockerfile
Expand All @@ -261,9 +250,9 @@ jobs:
- configure_builds
- build_and_push_amd64
- build_and_push_arm64
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix)}}
matrix: ${{ fromJson(needs.configure_builds.outputs.matrix) }}
permissions:
packages: write
steps:
Expand All @@ -274,11 +263,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout from GitHub
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: ${{ inputs.gitRef || github.ref }}

show-progress: false

- name: Create SHA manifest and push for Ruby Base Images
run: |
docker manifest create \
Expand All @@ -302,7 +291,7 @@ jobs:
--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 \
Expand Down
File renamed without changes.

0 comments on commit 330b7ae

Please sign in to comment.