Skip to content

Commit 4d28825

Browse files
Use git credential helper for secure authentication
Co-authored-by: volodymyr-memsql <57520563+volodymyr-memsql@users.noreply.github.com>
1 parent b9e2594 commit 4d28825

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/publish-release-assets.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,16 @@ jobs:
130130
git config --global user.email "github-actions[bot]@users.noreply.github.com"
131131
git config --global user.name "github-actions[bot]"
132132
133-
# Push the tag using authenticated URL
134-
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git "${TAG_NAME}"
133+
# Configure git credentials securely using credential helper
134+
# This keeps the token out of the command line and git URLs
135+
git config --global credential.helper 'cache --timeout=300'
136+
echo "protocol=https
137+
host=github.com
138+
username=x-access-token
139+
password=${GH_TOKEN}" | git credential approve
140+
141+
# Push the tag using standard remote (credentials from helper)
142+
git push origin "${TAG_NAME}"
135143
fi
136144

137145
# Create release with options (avoiding eval for security)

IMPLEMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The implementation includes multiple security measures:
4242

4343
### Git Push Authentication Issue
4444
- **Problem**: When pushing tags, git would fail with "could not read Username for 'https://github.com'" because HTTPS authentication wasn't configured
45-
- **Solution**: Changed to use token-authenticated URL format (`https://x-access-token:${GH_TOKEN}@github.com/${repo}.git`) for pushing tags, which provides authentication inline
45+
- **Solution**: Configured git credential helper to securely provide authentication using the GitHub token, avoiding exposing the token in command-line arguments or URLs
4646

4747
## Setup Required
4848

0 commit comments

Comments
 (0)