temp(tags): Set tags to test branch #14
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
# GitHub actions workflow which builds and publishes the docker images. | |
name: Build and Merge Docker Images | |
on: | |
push: | |
tags: ["v*"] | |
branches: [ fix-docker-build-architecture ] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
packages: write | |
id-token: write # needed for signing the images with GitHub OIDC Token | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm/v6 | |
- linux/arm/v7 | |
- linux/arm64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64,arm/v6,arm/v7 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Inspect builder | |
run: docker buildx inspect | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Extract version from Cargo.toml | |
# Note: explicitly requesting bash will mean bash is invoked with `-eo pipefail`, see | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell | |
shell: bash | |
run: | | |
echo "ELICHIKA_VERSION=0.1" >> $GITHUB_ENV | |
- name: Log in to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Calculate docker image tag | |
id: set-tag | |
uses: docker/metadata-action@master | |
with: | |
images: | | |
docker.io/yunimoo/elichika | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/fix-docker-build-architecture' }} | |
type=pep440,pattern={{raw}} | |
- name: Build and push all platforms | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
labels: | | |
gitsha1=${{ github.sha }} | |
org.opencontainers.image.version=${{ env.ELICHIKA_VERSION }} | |
tags: "${{ steps.set-tag.outputs.tags }}" | |
file: "docker/Dockerfile" | |
platforms: ${{ matrix.platform }} | |
# arm64 builds OOM without the git fetch setting. c.f. | |
# https://github.com/rust-lang/cargo/issues/10583 | |
build-args: | | |
CARGO_NET_GIT_FETCH_WITH_CLI=true | |
- name: Export digest | |
env: | |
DIGEST: ${{ steps.build-and-push.outputs.digest }} | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 7 | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@v3.5.0 | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create manifest list and push | |
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 ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
- name: Sign the images with GitHub OIDC Token | |
env: | |
DIGEST: ${{ steps.build-and-push.outputs.digest }} | |
TAGS: ${{ steps.set-tag.outputs.tags }} | |
run: | | |
images="" | |
for tag in ${TAGS}; do | |
images+="${tag}@${DIGEST} " | |
done | |
cosign sign --yes ${images} |