Skip to content

Docker

Docker #25

Workflow file for this run

# Build Hermes Docker image, push to GHCR.io.
name: Docker
on:
workflow_dispatch:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
env:
REGISTRY: ghcr.io
FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
# Checking out the repo
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: depot/setup-action@v1
- name: Login to Docker Hub
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'astriaorg/hermes'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Generate correct tabs and labels
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ghcr.io/astriaorg/hermes
tags: |
type=ref,event=pr
type=match,pattern=refs/tags/v(.*),group=1,enable=${{ startsWith(env.FULL_REF, 'refs/tags/') }},value=${{ env.FULL_REF }}
type=sha
# set latest tag for `main` branch
type=raw,value=latest,enable=${{ env.FULL_REF == format('refs/heads/{0}', 'main') }}
- name: Build and push
uses: depot/build-push-action@v1
with:
# this gets rid of the unknown/unknown image that is created without this setting
# https://github.com/docker/build-push-action/issues/820#issuecomment-1455687416
provenance: false
context: .
file: ci/release/hermes.Dockerfile
platforms: "linux/amd64,linux/arm64"
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'astriaorg/hermes' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
project: qz2p12cbtf