refactor(cleanup-release): 移除 RUNNER_TOKEN 輸入,一律改用 Gitea 自動 token
- action.yml 移除 RUNNER_TOKEN input 與 secrets 回退鏈,env 簡化為 GITEA_TOKEN: ${{ gitea.token }}
- src/index.js 環境變數與 log 訊息同步改名為 GITEA_TOKEN,遮罩行為不變
- 自動 token 權限僅限當前 repo 且 job 結束即失效,已足夠本 action 的 release/tag 清理需求
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
888d503d1d
commit
adab16fb45
+3
-7
@@ -1,5 +1,5 @@
|
||||
# 檔案用途:定義 CLEANUP OLD RELEASES 這個 Docker action 的輸入參數與執行環境
|
||||
# 更新日期:2026/07/11 21:02:25
|
||||
# 更新日期:2026/07/15 11:17:00
|
||||
|
||||
# Action 名稱,會顯示在 action 市集與文件中
|
||||
name: 'CLEANUP OLD RELEASES'
|
||||
@@ -12,10 +12,6 @@ author: 'Jeffery'
|
||||
|
||||
# 定義可由使用者或呼叫端傳入的輸入參數
|
||||
inputs:
|
||||
# RUNNER_TOKEN 用於授權呼叫 Gitea API;未提供時會改用 secrets
|
||||
RUNNER_TOKEN:
|
||||
# 參數說明,讓呼叫端知道這是 Runner Token
|
||||
description: 'Gitea Runner Token'
|
||||
# KEEP_COUNT 用於控制保留的 release 數量
|
||||
KEEP_COUNT:
|
||||
# 參數說明,這裡表示保留的版本數量
|
||||
@@ -35,7 +31,7 @@ runs:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
# GITEA_REPOSITORY 由 Gitea runtime 注入,供程式指定目標 repo
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
# 優先使用傳入的 RUNNER_TOKEN,否則退回 Gitea token secrets
|
||||
RUNNER_TOKEN: ${{ inputs.RUNNER_TOKEN || secrets.GITEA_TOKEN || secrets.RUNNER_TOKEN }}
|
||||
# 使用 Gitea runtime 自動核發的 token,權限僅限當前 repo 且 job 結束即失效
|
||||
GITEA_TOKEN: ${{ gitea.token }}
|
||||
# KEEP_COUNT 直接沿用輸入值,交由程式驗證
|
||||
KEEP_COUNT: ${{ inputs.KEEP_COUNT }}
|
||||
|
||||
+5
-5
@@ -400,7 +400,7 @@ function hasBatchFailure(results) {
|
||||
async function main() {
|
||||
const GITEA_SERVER_URL = normalizeEnvValue(process.env.GITEA_SERVER_URL);
|
||||
const GITEA_REPOSITORY = normalizeEnvValue(process.env.GITEA_REPOSITORY);
|
||||
const RUNNER_TOKEN = normalizeEnvValue(process.env.RUNNER_TOKEN) ?? '';
|
||||
const GITEA_TOKEN = normalizeEnvValue(process.env.GITEA_TOKEN) ?? '';
|
||||
const KEEP_COUNT = normalizeEnvValue(process.env.KEEP_COUNT) ?? '';
|
||||
const MAX_PAGES = normalizeEnvValue(process.env.MAX_PAGES) ?? '';
|
||||
|
||||
@@ -421,11 +421,11 @@ async function main() {
|
||||
|
||||
const keepCount = Number(KEEP_COUNT);
|
||||
const authHeaders = {};
|
||||
if (isEmptyOrNull(RUNNER_TOKEN)) {
|
||||
warn('RUNNER_TOKEN is empty; release API calls will be anonymous');
|
||||
if (isEmptyOrNull(GITEA_TOKEN)) {
|
||||
warn('GITEA_TOKEN is empty; release API calls will be anonymous');
|
||||
} else {
|
||||
info('RUNNER_TOKEN=[redacted]');
|
||||
authHeaders.Authorization = `token ${RUNNER_TOKEN}`;
|
||||
info('GITEA_TOKEN=[redacted]');
|
||||
authHeaders.Authorization = `token ${GITEA_TOKEN}`;
|
||||
}
|
||||
|
||||
const serverBase = new URL(GITEA_SERVER_URL);
|
||||
|
||||
Reference in New Issue
Block a user