feat(config): support multiple Gitea profiles via GITEA_PROFILE env var

未設時讀 config.env(行為不變);設了讀 config.<profile>.env。
.gitignore 新增 config.*.env 但保留 config.example.env。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
timmy
2026-04-21 16:18:16 +08:00
parent e333f7b8ab
commit f28f20ba56
6 changed files with 41 additions and 3 deletions

View File

@@ -12,7 +12,12 @@ set -euo pipefail
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_SKILL_DIR="$(cd "${_LIB_DIR}/../.." && pwd)"
CONFIG_FILE="${_SKILL_DIR}/config.env"
# GITEA_PROFILE 未設 → 讀 config.env設了 → 讀 config.<profile>.env
if [[ -n "${GITEA_PROFILE:-}" ]]; then
CONFIG_FILE="${_SKILL_DIR}/config.${GITEA_PROFILE}.env"
else
CONFIG_FILE="${_SKILL_DIR}/config.env"
fi
GITEA_API_RESP_FILE=""
_cleanup_common() {
@@ -52,6 +57,10 @@ load_config() {
echo " cp ${_SKILL_DIR}/config.example.env ${CONFIG_FILE}"
echo ""
echo "然後編輯 ${CONFIG_FILE} 填入 GITEA_URL / GITEA_USER / GITEA_TOKEN"
if [[ -n "${GITEA_PROFILE:-}" ]]; then
echo ""
echo "(目前使用 profile${GITEA_PROFILE}"
fi
} >&2
exit 1
fi