Files
cleanup-release-action/action.yml
2025-12-01 12:03:51 +08:00

53 lines
1.6 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: 'Cleanup Old Releases'
description: '自動清理舊版本的 releases保留指定數量的最新版本'
inputs:
gitea-server:
description: 'Gitea 伺服器 URL'
required: true
repository:
description: '儲存庫名稱 (格式: owner/repo)'
required: true
package-name:
description: 'Container 套件名稱 (選填,若提供則會清理 Container Registry)'
required: false
default: ''
token:
description: 'Gitea API Token'
required: true
keep-count:
description: '保留的最新版本數量'
required: false
default: '2'
dry-run:
description: '是否為模擬執行 (只顯示會刪除的版本,不實際刪除)'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: 清理舊版本
id: cleanup
shell: bash
run: |
chmod +x "${{ github.action_path }}/cleanup-releases.sh"
"${{ github.action_path }}/cleanup-releases.sh" \
"${{ inputs.gitea-server }}" \
"${{ inputs.repository }}" \
"${{ inputs.token }}" \
"${{ inputs.keep-count }}" \
"${{ inputs.dry-run }}"
- name: 清理舊映像
id: cleanup-images
if: inputs.package-name != ''
shell: bash
run: |
chmod +x "${{ github.action_path }}/cleanup-images.sh"
"${{ github.action_path }}/cleanup-images.sh" \
"${{ inputs.gitea-server }}" \
"${{ inputs.repository }}" \
"${{ inputs.package-name }}" \
"${{ inputs.token }}" \
"${{ inputs.keep-count }}" \
"${{ inputs.dry-run }}"