fix(ci): 修正 Release workflow 確保 Docker Image 正確發佈
- dockerhub-description.yml: - 修正 IMAGE_NAME 為 convertx/convertx-cn - 新增 continue-on-error 避免阻擋 Release - 新增 workflow_run 觸發器 - release.yml: - 新增 workflow_dispatch 手動觸發支援 - 新增 permissions 設定 - 優化 disk cleanup 錯誤處理 - docker-publish.yml: - 修正 DOCKERHUB_USERNAME 從 secrets 讀取 - 修正 DOCKER_IMAGE 為正確的 convertx/convertx-cn
This commit is contained in:
parent
f675a68d87
commit
44152ff872
3 changed files with 81 additions and 25 deletions
13
.github/workflows/docker-publish.yml
vendored
13
.github/workflows/docker-publish.yml
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|
||||||
# thanks to https://github.com/sredevopsorg/multi-arch-docker-github-workflow
|
# thanks to https://github.com/sredevopsorg/multi-arch-docker-github-workflow
|
||||||
|
# This workflow builds and publishes to GHCR (GitHub Container Registry)
|
||||||
|
# For Docker Hub releases, see release.yml
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -9,9 +11,12 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
# GitHub Container Registry image name
|
||||||
DOCKERHUB_USERNAME: c4illin
|
GHCR_IMAGE: ghcr.io/${{ github.repository }}
|
||||||
|
# Docker Hub image name (for merge job)
|
||||||
|
DOCKER_IMAGE: convertx/convertx-cn
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
@ -161,7 +166,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/${{ env.REPO }}
|
ghcr.io/${{ env.REPO }}
|
||||||
${{ env.IMAGE_NAME }}
|
${{ env.DOCKER_IMAGE }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
@ -176,7 +181,7 @@ jobs:
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Get execution timestamp with RFC3339 format
|
- name: Get execution timestamp with RFC3339 format
|
||||||
|
|
|
||||||
37
.github/workflows/dockerhub-description.yml
vendored
37
.github/workflows/dockerhub-description.yml
vendored
|
|
@ -1,8 +1,12 @@
|
||||||
name: Update Docker Hub Description
|
name: Update Docker Hub Description
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# 🔧 非關鍵流程 - 即使失敗也不影響 Release
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
# Docker Hub Repository 名稱(與 GitHub repo 不同)
|
||||||
DOCKERHUB_USERNAME: c4illin
|
DOCKER_IMAGE: convertx/convertx-cn
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -11,17 +15,34 @@ on:
|
||||||
paths:
|
paths:
|
||||||
- README.md
|
- README.md
|
||||||
- .github/workflows/dockerhub-description.yml
|
- .github/workflows/dockerhub-description.yml
|
||||||
|
# 也在 Release 完成後觸發
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Release"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
dockerHubDescription:
|
dockerHubDescription:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
# 只在 workflow_run 成功或直接 push 時執行
|
||||||
- uses: actions/checkout@v6
|
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
|
||||||
- name: Docker Hub Description
|
steps:
|
||||||
uses: peter-evans/dockerhub-description@v5
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Update Docker Hub Description
|
||||||
|
# 非關鍵流程 - 失敗不阻擋
|
||||||
|
continue-on-error: true
|
||||||
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
repository: ${{ env.IMAGE_NAME }}
|
repository: ${{ env.DOCKER_IMAGE }}
|
||||||
short-description: ${{ github.event.repository.description }}
|
short-description: ${{ github.event.repository.description }}
|
||||||
enable-url-completion: true
|
enable-url-completion: true
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: |
|
||||||
|
echo "## 📝 Docker Hub Description Update" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "Repository: \`${{ env.DOCKER_IMAGE }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
|
||||||
56
.github/workflows/release.yml
vendored
56
.github/workflows/release.yml
vendored
|
|
@ -4,13 +4,26 @@ on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*"
|
- "v*.*.*"
|
||||||
|
# 允許手動觸發
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Tag to release (e.g., v0.1.6)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_IMAGE: convertx/convertx-cn
|
DOCKER_IMAGE: convertx/convertx-cn
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# ==============================================================================
|
||||||
|
# 🐳 Build and Push Docker Image(關鍵流程)
|
||||||
|
# ==============================================================================
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
|
@ -25,27 +38,32 @@ jobs:
|
||||||
df -h
|
df -h
|
||||||
|
|
||||||
# 移除不需要的預裝軟體
|
# 移除不需要的預裝軟體
|
||||||
sudo rm -rf /usr/share/dotnet
|
sudo rm -rf /usr/share/dotnet || true
|
||||||
sudo rm -rf /usr/local/lib/android
|
sudo rm -rf /usr/local/lib/android || true
|
||||||
sudo rm -rf /opt/ghc
|
sudo rm -rf /opt/ghc || true
|
||||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
||||||
sudo rm -rf /usr/local/share/boost
|
sudo rm -rf /usr/local/share/boost || true
|
||||||
sudo rm -rf /usr/share/swift
|
sudo rm -rf /usr/share/swift || true
|
||||||
sudo rm -rf /opt/hostedtoolcache
|
sudo rm -rf /opt/hostedtoolcache || true
|
||||||
|
|
||||||
# 清理 apt cache
|
# 清理 apt cache
|
||||||
sudo apt-get clean
|
sudo apt-get clean || true
|
||||||
sudo apt-get autoremove -y
|
sudo apt-get autoremove -y || true
|
||||||
|
|
||||||
# 清理 Docker 舊資料
|
# 清理 Docker 舊資料
|
||||||
docker system prune -af --volumes || true
|
docker system prune -af --volumes || true
|
||||||
|
|
||||||
echo "After cleanup:"
|
echo "✅ After cleanup:"
|
||||||
df -h
|
df -h
|
||||||
|
|
||||||
- name: Get tag name
|
- name: Get tag name
|
||||||
id: tag
|
id: tag
|
||||||
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
@ -71,14 +89,21 @@ jobs:
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Summary
|
- name: Docker Build Summary
|
||||||
run: |
|
run: |
|
||||||
echo "## 🐳 Docker Image Published" >> $GITHUB_STEP_SUMMARY
|
echo "## 🐳 Docker Image Published" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Repository:** \`${{ env.DOCKER_IMAGE }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
|
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`${{ env.DOCKER_IMAGE }}:${{ steps.tag.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- \`${{ env.DOCKER_IMAGE }}:${{ steps.tag.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`${{ env.DOCKER_IMAGE }}:latest\`" >> $GITHUB_STEP_SUMMARY
|
echo "- \`${{ env.DOCKER_IMAGE }}:latest\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# 📦 Create GitHub Release
|
||||||
|
# ==============================================================================
|
||||||
create-release:
|
create-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
|
|
@ -93,7 +118,12 @@ jobs:
|
||||||
|
|
||||||
- name: Get tag name
|
- name: Get tag name
|
||||||
id: tag
|
id: tag
|
||||||
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Generate changelog
|
- name: Generate changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue