Publish to Docker Hub #162
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
name: Publish to Docker Hub | |
on: | |
workflow_run: | |
workflows: [Test and Build] | |
types: | |
- completed | |
env: | |
REGISTRY: docker.io | |
IMAGE_NAME: ${{ github.repository }} | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME || 'unpublished' }} | |
jobs: | |
test-and-build: | |
uses: ./.github/workflows/test-and-build.yaml | |
docker-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
needs: test-and-build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/cosign-installer@v3 | |
with: | |
cosign-release: 'v2.1.1' | |
- name: Get packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: build | |
- 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: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract Docker metadata - processor | |
id: processor_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKERHUB_USERNAME }}/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.DOCKERHUB_USERNAME }}/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 }} |