Skip to content

Commit

Permalink
Fix image name conflicts and add build attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
garyttierney committed Oct 11, 2024
1 parent 8852f3a commit 44fd34e
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
push:

env:
REGISTRY_IMAGE: digirati-co-uk/laya
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

name: "${{ matrix.build_configuration.name }}"
runs-on: ubuntu-latest
concurrency:
Expand All @@ -31,6 +33,11 @@ jobs:
triple: aarch64-unknown-linux-gnu
cpu: neoverse-v2
name: aws-graviton4
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Prepare
run: |
Expand All @@ -41,7 +48,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
# tag event
Expand All @@ -61,17 +68,31 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.build_configuration.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=false
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=false
build-args: |
TARGET=${{ matrix.build_configuration.triple }}
TARGET_CPU=${{ matrix.build_configuration.cpu }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true

- name: Export digest
run: |
mkdir -p /tmp/digests
Expand Down Expand Up @@ -111,8 +132,8 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

0 comments on commit 44fd34e

Please sign in to comment.