Skip to content

Commit

Permalink
Publish to GitHub Package Registry and Docker Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzo committed Jul 15, 2024
1 parent 4a989a2 commit 20587d7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup-host/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Setup Host'
description: 'Configures the host runner to run the build'

runs:
using: "composite"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
32 changes: 10 additions & 22 deletions .github/workflows/build-flavor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,15 @@ jobs:
outputs:
digest-prefix: ${{ env.TAG_PREFIX_DIGEST }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up host
uses: ./.github/actions/setup-host
- 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
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
env:
GCR_IO_REGISTRY: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
with:
buildkitd-config-inline: ${{ inputs.only-validate && env.GCR_IO_REGISTRY || '' }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
Expand Down Expand Up @@ -104,27 +93,26 @@ jobs:
needs: build
if: ${{ !inputs.only-validate }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up host
uses: ./.github/actions/setup-host
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ needs.build.outputs.digest-prefix }}_*
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 }}
tags: |
${{ inputs.latest && 'type=raw,value=latest' || '' }}
${{ inputs.latest && 'type=raw,value=ghcr.io/latest' || '' }}
type=raw,value=${{ env.TAG_PREFIX }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
type=raw,value=ghcr.io/${{ env.TAG_PREFIX }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
Expand Down

0 comments on commit 20587d7

Please sign in to comment.