Skip to content

Publish to GHCR

Publish to GHCR #6

Workflow file for this run

name: Publish to GHCR
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
call_tests:
uses: ./.github/workflows/tests.yml
build-image:
name: Build and push Docker image
needs: call_tests
if: success()
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Downcase registry owner
run: |
echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> ${GITHUB_ENV}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.OWNER_LC }}/zodd-web
# `latest` is reserved for actual tag pushes; manual workflow_dispatch
# runs publish under `develop` instead so they cannot overwrite a
# released image.
tags: |
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
type=raw,value=develop,enable=${{ github.event_name == 'workflow_dispatch' }}
type=ref,event=tag
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}