ci: build multi-platform container images #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "Build" | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
image: | |
name: "Container Image" | |
runs-on: "ubuntu-22.04" | |
permissions: | |
contents: "read" | |
id-token: "write" | |
packages: "write" | |
strategy: | |
matrix: | |
images: | |
- arch: "amd64" | |
- arch: "arm64" | |
fail-fast: true | |
steps: | |
- name: "Checkout repository" | |
id: "checkout" | |
uses: "actions/checkout@v4" | |
- name: "Set up Dagger" | |
id: "setup-dagger" | |
uses: "camptocamp/setup-dagger@v1" | |
with: | |
cloud-token: "${{ secrets.DAGGER_CLOUD_TOKEN }}" | |
- name: "Login to GitHub Container Registry" | |
uses: "docker/login-action@v3" | |
with: | |
registry: "ghcr.io" | |
username: "${{ github.actor }}" | |
password: "${{ secrets.GITHUB_TOKEN }}" | |
- name: "Build container image" | |
id: "build-image" | |
run: | | |
address='ghcr.io/${{ github.repository_owner }}/varnish:${{ github.ref_name }}' | |
ref="$(dagger call container --platform '${{ matrix.images.arch }}' publish --address "$address-${{ matrix.images.arch }}")" | |
docker manifest create --amend "$address" "$ref" | |
- name: "Delete old container images" | |
id: "delete-old-images" | |
uses: "actions/delete-package-versions@v5" | |
with: | |
package-name: "varnish" | |
package-type: "container" | |
min-versions-to-keep: 0 | |
delete-only-untagged-versions: true |