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
|
||||
|
||||
# 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:
|
||||
push:
|
||||
|
|
@ -9,9 +11,12 @@ on:
|
|||
pull_request:
|
||||
branches: ["main"]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: c4illin
|
||||
# GitHub Container Registry image name
|
||||
GHCR_IMAGE: ghcr.io/${{ github.repository }}
|
||||
# Docker Hub image name (for merge job)
|
||||
DOCKER_IMAGE: convertx/convertx-cn
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
|
@ -161,7 +166,7 @@ jobs:
|
|||
with:
|
||||
images: |
|
||||
ghcr.io/${{ env.REPO }}
|
||||
${{ env.IMAGE_NAME }}
|
||||
${{ env.DOCKER_IMAGE }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
|
@ -176,7 +181,7 @@ jobs:
|
|||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- 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
|
||||
|
||||
# ==============================================================================
|
||||
# 🔧 非關鍵流程 - 即使失敗也不影響 Release
|
||||
# ==============================================================================
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: c4illin
|
||||
# Docker Hub Repository 名稱(與 GitHub repo 不同)
|
||||
DOCKER_IMAGE: convertx/convertx-cn
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -11,17 +15,34 @@ on:
|
|||
paths:
|
||||
- README.md
|
||||
- .github/workflows/dockerhub-description.yml
|
||||
# 也在 Release 完成後觸發
|
||||
workflow_run:
|
||||
workflows: ["Release"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
# 只在 workflow_run 成功或直接 push 時執行
|
||||
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
|
||||
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Update Docker Hub Description
|
||||
# 非關鍵流程 - 失敗不阻擋
|
||||
continue-on-error: true
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USERNAME }}
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: ${{ env.IMAGE_NAME }}
|
||||
repository: ${{ env.DOCKER_IMAGE }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
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:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
# 允許手動觸發
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Tag to release (e.g., v0.1.6)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
DOCKER_IMAGE: convertx/convertx-cn
|
||||
|
||||
jobs:
|
||||
# ==============================================================================
|
||||
# 🐳 Build and Push Docker Image(關鍵流程)
|
||||
# ==============================================================================
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
|
@ -25,27 +38,32 @@ jobs:
|
|||
df -h
|
||||
|
||||
# 移除不需要的預裝軟體
|
||||
sudo rm -rf /usr/share/dotnet
|
||||
sudo rm -rf /usr/local/lib/android
|
||||
sudo rm -rf /opt/ghc
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||
sudo rm -rf /usr/local/share/boost
|
||||
sudo rm -rf /usr/share/swift
|
||||
sudo rm -rf /opt/hostedtoolcache
|
||||
sudo rm -rf /usr/share/dotnet || true
|
||||
sudo rm -rf /usr/local/lib/android || true
|
||||
sudo rm -rf /opt/ghc || true
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
||||
sudo rm -rf /usr/local/share/boost || true
|
||||
sudo rm -rf /usr/share/swift || true
|
||||
sudo rm -rf /opt/hostedtoolcache || true
|
||||
|
||||
# 清理 apt cache
|
||||
sudo apt-get clean
|
||||
sudo apt-get autoremove -y
|
||||
sudo apt-get clean || true
|
||||
sudo apt-get autoremove -y || true
|
||||
|
||||
# 清理 Docker 舊資料
|
||||
docker system prune -af --volumes || true
|
||||
|
||||
echo "After cleanup:"
|
||||
echo "✅ After cleanup:"
|
||||
df -h
|
||||
|
||||
- name: Get tag name
|
||||
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
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
|
@ -71,14 +89,21 @@ jobs:
|
|||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Summary
|
||||
- name: Docker Build Summary
|
||||
run: |
|
||||
echo "## 🐳 Docker Image Published" >> $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 "- \`${{ env.DOCKER_IMAGE }}:${{ steps.tag.outputs.version }}\`" >> $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:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
|
|
@ -93,7 +118,12 @@ jobs:
|
|||
|
||||
- name: Get tag name
|
||||
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
|
||||
id: changelog
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue