♻️ refactor(ci): 将 GIT_CONFIG 环境变量改为内联 -c 认证

- 删除三个 workflow env 段的 GIT_CONFIG_COUNT/KEY/VALUE 变量
- 在需要认证的 git 命令上内联 -c credential.helper/interactive
- prepare fetch、stats 两处 push、release push 各自内联
- 保留 ACCESS_TOKEN,helper 运行时取用
This commit is contained in:
csh
2026-07-20 16:39:08 +08:00
parent 2dcf9f7da4
commit ac8a781656
3 changed files with 19 additions and 25 deletions
+10 -9
View File
@@ -17,13 +17,6 @@ env:
# ===== Token 配置 =====
# 请在 Settings -> Secrets 中配置 WORKFLOW secret
ACCESS_TOKEN: ${{ secrets.WORKFLOW }}
GIT_CONFIG_COUNT: "3"
GIT_CONFIG_KEY_0: "credential.helper"
GIT_CONFIG_VALUE_0: ""
GIT_CONFIG_KEY_1: "credential.helper"
GIT_CONFIG_VALUE_1: '!f() { test "$1" = get || exit 0; printf "%s\n" username=oauth2; printf "%s\n" "password=${ACCESS_TOKEN}"; }; f'
GIT_CONFIG_KEY_2: "credential.interactive"
GIT_CONFIG_VALUE_2: "never"
# ===== 工作区配置 =====
WORKSPACE_ROOT: "/data/workspace"
@@ -287,7 +280,11 @@ jobs:
git commit -m ":bar_chart: chore(stats): 初始化统计分支"
# 推送到远程
git -C "${{ env.REPO_DIR }}" push origin "${{ env.BADGE_BRANCH }}"
git -C "${{ env.REPO_DIR }}" \
-c credential.helper= \
-c 'credential.helper=!f() { test "$1" = get || exit 0; printf "%s\n" username=oauth2; printf "%s\n" "password=${ACCESS_TOKEN}"; }; f' \
-c credential.interactive=never \
push origin "${{ env.BADGE_BRANCH }}"
echo "✅ 统计分支创建完成"
echo "======================================"
@@ -522,7 +519,11 @@ jobs:
echo "📤 推送到远程 ${{ env.BADGE_BRANCH }} 分支..."
# 推送到远程(使用 TOKEN)
if git -C "${{ env.REPO_DIR }}" push origin "${{ env.BADGE_BRANCH }}"; then
if git -C "${{ env.REPO_DIR }}" \
-c credential.helper= \
-c 'credential.helper=!f() { test "$1" = get || exit 0; printf "%s\n" username=oauth2; printf "%s\n" "password=${ACCESS_TOKEN}"; }; f' \
-c credential.interactive=never \
push origin "${{ env.BADGE_BRANCH }}"; then
echo "✅ 推送成功"
echo "changed=true" >> $GITHUB_OUTPUT
else