Publish Docker image #44
Workflow file for this run
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 Docker image | |
# Tagging a release 'vX' will create an image named "paulgalow/racoder:vX" and one for ":latest" | |
# Tagging a release with 'unstable' will create an image named "paulgalow/racoder:unstable" | |
on: | |
push: | |
tags: | |
- "*" | |
workflow_dispatch: # Enables manual triggering | |
inputs: | |
tags: | |
description: "Please specify version tag to build and push" | |
required: true | |
jobs: | |
push_to_registries: | |
name: Push Docker image to multiple registries | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.tags || github.ref }} | |
- name: Debug - Print Current Branch/Tag | |
run: 'echo "Current Branch/Tag: $(git rev-parse --abbrev-ref HEAD)"' | |
- name: Set up QEMU for more CPU architectures | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx for multi-platform builds | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Extract metadata (tags, labels) for Docker | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# images: | | |
# ${{ github.repository }} | |
# ghcr.io/${{ github.repository }} | |
# tags: | | |
# type=ref,event=tag,prefix=v,format=latest # Apply 'latest' tag for versioned tags | |
# type=ref,event=tag,prefix=v # Apply versioned tag like 'v1.0.0' | |
# type=ref,event=tag,excludePrefix=v # Apply non-versioned tag | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=${{ github.event.inputs.tags || github.ref_name }} | |
type=semver,pattern={{version}},value=${{ github.event.inputs.tags || github.ref_name }} | |
type=semver,pattern={{version}},value=${{ github.event.inputs.tags || github.ref_name }},format=latest | |
- name: Debug - Print generated tags | |
run: 'echo "Generated Tags: ${{ steps.meta.outputs.tags }}"' | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |