Files
vrc-ytdlp-resolver/.github/workflows/docker-publish.yml
2025-11-09 13:13:44 +01:00

69 lines
1.8 KiB
YAML

name: Build & Publish Docker image to Docker Hub
on:
push:
branches: [ "main" ]
tags:
- "v*"
workflow_dispatch:
concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true
env:
# Change this if your Docker Hub namespace differs from your username
DOCKERHUB_NAMESPACE: ${{ secrets.DOCKERHUB_USERNAME }}
IMAGE_NAME: vrc-ytdlp-resolver
PLATFORMS: linux/amd64,linux/arm64
jobs:
docker:
name: Build & Push
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- 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: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
# latest for main branch
type=raw,value=latest,enable={{is_default_branch}}
# git sha
type=sha
# semver tags like v1.2.3 -> 1.2.3, 1.2, 1
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build & Push (multi-arch)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max