ci: replace metadata-action with reusable auto-tag action

This commit is contained in:
Haitao Pan 2025-12-03 18:35:03 +08:00
parent 3fb57b094c
commit 33958d6da8
2 changed files with 49 additions and 5 deletions

37
.github/actions/auto-tag/action.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: "Cloud-Neutral Auto Tag"
description: "Generate Docker tags for main, release, PR and dev branches"
inputs:
image:
description: "Base image name (e.g. ghcr.io/.../image)"
required: true
outputs:
tags:
description: "Generated Docker tags"
value: ${{ steps.meta.outputs.tags }}
labels:
description: "Generated Docker labels"
value: ${{ steps.meta.outputs.labels }}
runs:
using: composite
steps:
- name: Generate metadata (auto tags)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
tags: |
# main → latest
type=raw,enable=${{ github.ref == 'refs/heads/main' }},value=latest
# release tagv1.2.3
type=ref,event=tag
type=semver,pattern={{version}}
# PR → pr-123
type=raw,enable=${{ startsWith(github.ref, 'refs/pull/') }},value=pr-${{ github.event.pull_request.number }}
# dev/feature branches → branch name
type=ref,event=branch

View File

@ -47,13 +47,20 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
#- uses: docker/metadata-action@v5
# id: meta
# with:
# images: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ matrix.image.name }}
# tags: |
# type=sha
# type=raw,value=latest
- name: Generate Auto Tags
id: meta
uses: ./.github/actions/auto-tag
with:
images: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ matrix.image.name }}
tags: |
type=sha
type=raw,value=latest
image: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ matrix.image.name }}
- uses: docker/setup-qemu-action@v3