Skip to content

Publish Docker Images #8

Publish Docker Images

Publish Docker Images #8

name: Publish Docker Images
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Image tag to publish (example: v1.1.0). Leave empty to use current git tag or sha."
required: false
type: string
permissions:
contents: read
packages: write
jobs:
publish:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
VERSION: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.version || github.ref_name || github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Normalize image namespace
run: |
echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV"
echo "REPO_LC=${REPO,,}" >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push CPU image
run: |
docker buildx bake cpu \
--set cpu.platform=linux/amd64,linux/arm64 \
--set cpu.tags=${REGISTRY}/${OWNER_LC}/${REPO_LC}-cpu:${VERSION} \
--push
- name: Create CPU latest tag alias
run: |
docker buildx imagetools create \
--tag ${REGISTRY}/${OWNER_LC}/${REPO_LC}-cpu:latest \
${REGISTRY}/${OWNER_LC}/${REPO_LC}-cpu:${VERSION}
- name: Build and push GPU image
run: |
docker buildx bake gpu \
--set gpu.platform=linux/amd64 \
--set gpu.tags=${REGISTRY}/${OWNER_LC}/${REPO_LC}-gpu:${VERSION} \
--push
- name: Create GPU latest tag alias
run: |
docker buildx imagetools create \
--tag ${REGISTRY}/${OWNER_LC}/${REPO_LC}-gpu:latest \
${REGISTRY}/${OWNER_LC}/${REPO_LC}-gpu:${VERSION}