Skip to content

Commit

Permalink
Also publish to Docker Hub
Browse files Browse the repository at this point in the history
Until we are allowed to pull from ghcr.io (SET-661).

Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com>
  • Loading branch information
nicolasbock committed May 6, 2024
1 parent 56237b2 commit 31188ec
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 7 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Publish to Docker Hub

on:
schedule:
- cron: '31 13 * * *'
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.1.1'

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Test and Build
run: make all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata - processor
id: processor_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/athena-processor

- name: Build and publish Docker - processor
id: processor-build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/processor/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.processor_meta.outputs.tags }}
labels: ${{ steps.processor_meta.outputs.labels }}

- name: Extract Docker metadata - monitor
id: monitor_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/athena-monitor

- name: Build and publish Docker - monitor
id: monitor_build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/monitor/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.monitor_meta.outputs.tags }}
labels: ${{ steps.monitor_meta.outputs.labels }}
12 changes: 5 additions & 7 deletions .github/workflows/ghcr-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ on:
schedule:
- cron: '38 11 * * *'
push:
branches: ["main"]
# Publish semver tags as releases.
tags: ['v*.*.*']
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: ["main"]
branches: [ "main" ]
workflow_dispatch:

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -38,7 +36,7 @@ jobs:
- name: Test and Build
run: make all

- name: Setup Docker buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup QEMU
Expand Down

0 comments on commit 31188ec

Please sign in to comment.