feat: resolve gitea token sources

This commit is contained in:
2026-05-15 01:46:46 +00:00
parent c7584316ba
commit 19e863e0aa
3 changed files with 55 additions and 20 deletions
Regular → Executable
+45 -5
View File
@@ -1,11 +1,51 @@
#!/bin/bash
set -euo pipefail
echo "Gitea Server Url: $GITEA_SERVER_URL"
log() {
printf '%s\n' "$*" >&2
}
echo "Gitea Repository: $GITEA_REPOSITORY"
fail() {
log "ERROR: $*"
exit 1
}
echo "Gitea Runner Token: $RUNNER_TOKEN"
resolve_token() {
local source_name env_value
local sources=(
"inputs.RUNNER_TOKEN:INPUT_RUNNER_TOKEN"
"secrets.GITEA_TOKEN:GITEA_TOKEN"
"secrets.RUNNER_TOKEN:RUNNER_TOKEN_SECRET"
)
echo "Input Text: $INPUT_TEXT"
for source in "${sources[@]}"; do
source_name="${source%%:*}"
env_value="${source#*:}"
log "Trying token from ${source_name}"
if [[ -n "${!env_value:-}" ]]; then
log "Using token from ${source_name}"
printf '%s' "${!env_value}"
return 0
fi
log "Token not found in ${source_name}, trying next source"
done
echo "text=$INPUT_TEXT" >> "$GITHUB_OUTPUT"
return 1
}
main() {
local token
log "Gitea Server Url: ${GITEA_SERVER_URL:-}"
log "Gitea Repository: ${GITEA_REPOSITORY:-}"
if ! token="$(resolve_token)"; then
fail "No Gitea token available, exiting"
fi
export RESOLVED_GITEA_TOKEN="$token"
log "Token source resolved successfully"
log "Stage 1 complete"
}
main "$@"