Files
FileHost/.github/workflows/docker-publish.yml
T
O96u 80d2bca4e0 ci: build Docker image only on version tags
Stop publishing on main push and remove GHCR; images go to Docker Hub only.
2026-08-22 18:50:33 +08:00

57 lines
1.4 KiB
YAML

name: Publish Docker image
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
env:
IMAGE_NAME: pichost
jobs:
build-and-push:
if: ${{ !contains(github.event.head_commit.message, '[skip docker]') }}
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max