Skip to content

Commit

Permalink
add docker publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmorley committed Sep 23, 2024
1 parent f408e47 commit 50919b3
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release Docker image to GHCR

on:
# TODO: wire into release process
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
default: 'latest'

env:
REGISTRY: ghcr.io

jobs:
build:
permissions:
contents: read
packages: write
strategy:
matrix:
runner:
- ubuntu-22.04-medium-arm64
- ubuntu-22.04
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image by digest
uses: docker/build-push-action@v6
id: build
with:
context: docker
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
- 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: digests-${{ runner.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs: [build]
permissions:
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ github.repository }}:${{ inputs.version }} \
$(printf '${{ env.REGISTRY }}/${{ github.repository }}@sha256:%s ' *)

0 comments on commit 50919b3

Please sign in to comment.