Refactor CI workflow to simplify remote URL configuration #10

Merged
jusemon merged 1 commit from hotfix/fix-auth-git-issues into main 2025-11-26 12:52:52 -05:00
Showing only changes of commit 96a74dbad1 - Show all commits

View file

@ -187,20 +187,6 @@ jobs:
git config user.name "forgebot"
git config user.email "forgebot@forgejo.io"
# Configure remote URL with token for authentication
# Extract repository URL and add token
REPO_URL=$(git remote get-url origin)
# Handle both https and git@ formats
if [[ "$REPO_URL" == https://* ]]; then
# Extract domain and path from https URL
REPO_PATH=$(echo "$REPO_URL" | sed 's|https://||' | sed 's|git@||' | sed 's|:|/|')
git remote set-url origin "https://${{ secrets.FORGEBOT_ACCESS_TOKEN }}@${REPO_PATH}"
else
# For git@ format, convert to https with token
REPO_PATH=$(echo "$REPO_URL" | sed 's|git@||' | sed 's|:|/|')
git remote set-url origin "https://${{ secrets.FORGEBOT_ACCESS_TOKEN }}@${REPO_PATH}"
fi
# Fetch latest changes to avoid conflicts
git fetch origin main || echo "Fetch completed or already up to date"
git checkout main || echo "Already on main"
@ -231,7 +217,7 @@ jobs:
exit 0
}
# Push to main branch using the token
# Push to main branch (remote should already be configured with token)
git push origin main || {
echo "⚠️ Push failed (check token permissions)"
exit 0