Publish Docker image #43
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 | |
type: string | |
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: 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=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: 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 }} |