Publish Docker image #28
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 | |
- 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 (versioned tags) | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: meta_versioned | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
flavor: | | |
latest=true | |
- name: Extract metadata (tags, labels) for Docker (non-versioned tags) | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
id: meta_non_versioned | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
flavor: | | |
latest=false | |
- name: Build and push Docker images (versioned tags) | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm | |
push: true | |
tags: ${{ steps.meta_versioned.outputs.tags }} | |
labels: ${{ steps.meta_versioned.outputs.labels }} | |
- name: Build and push Docker images (non-versioned tags) | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm | |
push: true | |
tags: ${{ steps.meta_non_versioned.outputs.tags }} | |
labels: ${{ steps.meta_non_versioned.outputs.labels }} |