Skip to content

Commit

Permalink
Merge pull request #1382 from alphagov/rename-build-image-input
Browse files Browse the repository at this point in the history
Rename ecrRepository input for build image workflows
  • Loading branch information
theseanything authored Jul 10, 2024
2 parents ad5ce00 + 81b381b commit 1401d27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
required: false
type: string
default: ${{ github.event.repository.name }}
imageName:
required: false
type: string
default: ${{ github.event.repository.name }}
dockerfilePath:
required: false
type: string
Expand Down Expand Up @@ -57,7 +61,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }}
tags: |
type=raw,priority=500,value=${{ inputs.gitRef }},enable=${{ startsWith(inputs.gitRef, 'v') }}
type=raw,priority=400,value=${{ steps.local-head.outputs.sha }},enable=${{ !startsWith(inputs.gitRef, 'v') }}
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/build-and-push-multiarch-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
required: false
type: string
default: ${{ github.event.repository.name }}
imageName:
required: false
type: string
default: ${{ github.event.repository.name }}
dockerfilePath:
required: false
type: string
Expand All @@ -29,7 +33,7 @@ on:

jobs:
build-and-push-image:
name: Build and push image for ${{ inputs.ecrRepositoryName }}
name: Build and push image for ${{ inputs.ecrRepositoryName || inputs.imageName }}
strategy:
matrix:
arch:
Expand Down Expand Up @@ -71,7 +75,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }}
labels: |
org.opencontainers.image.vendor=GDS
tags: |
Expand All @@ -88,9 +92,9 @@ jobs:
provenance: false
build-args: ${{ inputs.buildArgs }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ inputs.ecrRepositoryName }}-${{ matrix.arch }}
cache-to: type=gha,scope=build-${{ inputs.ecrRepositoryName }}-${{ matrix.arch }},mode=max
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ inputs.ecrRepositoryName || inputs.imageName }}-${{ matrix.arch }}
cache-to: type=gha,scope=build-${{ inputs.ecrRepositoryName || inputs.imageName }}-${{ matrix.arch }},mode=max

- id: export-digests
env:
Expand All @@ -102,7 +106,7 @@ jobs:
- id: upload-digests
uses: actions/upload-artifact@v4
with:
name: digests-${{ inputs.ecrRepositoryName }}-${{ matrix.arch }}
name: digests-${{ inputs.ecrRepositoryName || inputs.imageName }}-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
Expand All @@ -122,7 +126,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ inputs.ecrRepositoryName }}-*
pattern: digests-${{ inputs.ecrRepositoryName || inputs.imageName }}-*
merge-multiple: true

- uses: docker/setup-buildx-action@v3
Expand All @@ -142,7 +146,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }}
labels: |
org.opencontainers.image.vendor=GDS
tags: |
Expand All @@ -152,7 +156,7 @@ jobs:
- name: Create Manifest Lists
env:
IMAGEREF_PREFIX: 'ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }}'
IMAGEREF_PREFIX: 'ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }}'
working-directory: /tmp/digests
run: |
tag_args=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
Expand All @@ -162,6 +166,6 @@ jobs:
- name: Inspect Images
env:
IMAGEREF: 'ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName }}:${{ steps.meta.outputs.version }}'
IMAGEREF: 'ghcr.io/${{ github.repository_owner }}/govuk/${{ inputs.ecrRepositoryName || inputs.imageName }}:${{ steps.meta.outputs.version }}'
run: |
docker buildx imagetools inspect "$IMAGEREF"

0 comments on commit 1401d27

Please sign in to comment.