Skip to content

ci: use unique artifact names #158

ci: use unique artifact names

ci: use unique artifact names #158

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Docker build & Push
# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
push:
tags:
- '5.*'
env:
DOCKER_REGISTRY_IMAGE: eveseat/seat
GHCR_REGISTRY_IMAGE: ghcr.io/eveseat/seat
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
image:
- eveseat/seat
- ghcr.io/eveseat/seat
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Clone repository
uses: actions/checkout@v4
- name: Get artifact name
id: getartifactname
run: echo "artifact=$(printf '%s-%s-digests' ${{ matrix.image }} ${{ matrix.platform }} | sed 's/\//-/g;s/\./-/g')" >> "$GITHUB_OUTPUT"
# Define tagging policy
# - everything coming in another branch than default one is considered edge (unstable)
# - everything coming in default branch is considered latest
# - all releases are tags with major, major.minor and version
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
flavor: |
latest=false
tags: |
type=raw,value=edge,enable=${{ github.ref_type == 'branch' && github.ref_name != 'master' }}
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && github.ref_name == 'master' }}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{major}}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{major}}.{{minor}}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{version}}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Build-X
uses: docker/setup-buildx-action@v3
- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Update embedded manifest
run: |
echo ${{ steps.meta.outputs.version }} > version
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ matrix.image }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,ref=eveseat/seat/${{ matrix.platform }}
cache-to: type=gha,mode=max,ref=eveseat/seat/${{ matrix.platform }}
- name: Export 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: ${{ steps.getartifactname.outputs.artifact }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
create-manifest:
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
image:
- eveseat/seat
- ghcr.io/eveseat/seat
steps:
- name: Get artifact name
id: getartifactname
run: echo "artifact=$(printf '%s-%s-digests' ${{ matrix.image }} ${{ matrix.platform }} | sed 's/\//-/g;s/\./-/g')" >> "$GITHUB_OUTPUT"
- name: Download digests
uses: actions/download-artifact@v3
with:
name: ${{ steps.getartifactname.outputs.artifact }}
path: /tmp/digests
- name: Set up Docker Build-X
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=edge,enable=${{ github.ref_type == 'branch' && github.ref_name != 'master' }}
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && github.ref_name == 'master' }}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{major}}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{major}}.{{minor}}
type=semver,enable=${{ github.ref_type == 'tag' }},pattern={{version}}
- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- 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 '${{ matrix.image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ matrix.image }}:${{ steps.meta.outputs.version }}