fix(cli,ci): keep --source value in flagsFirst and use GIT_ASKPASS for GitCode push

This commit is contained in:
Nwflower committed 2026-11-29 02:03:29 -07:00
1 parent f85e1aba88
commit 172df5c4d5
3 files changed
+24 -10

No files matched your search

+13 -4
View File
@@ -41,10 +41,19 @@ jobs:
exit 0
fi
git fetch --tags origin
# Configure token via extraheader so it never appears in remote URLs/logs.
auth="$(printf '%s:%s' "$GITCODE_USER" "$GITCODE_TOKEN" | base64 -w0)"
git -c "http.extraheader=Authorization: Basic $auth" push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
git -c "http.extraheader=Authorization: Basic $auth" push "https://gitcode.com/${GITCODE_REPO}.git" --tags
# Use GIT_ASKPASS so the token never appears in URLs or process argv.
askpass="$(mktemp)"
chmod 700 "$askpass"
cat > "$askpass" <<'EOF'
#!/bin/sh
case "$1" in
*Username*) printf '%s\n' "$GITCODE_USER" ;;
*) printf '%s\n' "$GITCODE_TOKEN" ;;
esac
EOF
trap 'rm -f "$askpass"' EXIT
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" --tags
- name: Sync Release and assets to GitCode
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.sync_releases)