Refactor CI workflow to simplify remote URL configuration
All checks were successful
Build and Publish Docker Image / Build and Validate (pull_request) Successful in 8s
Build and Publish Docker Image / Publish to Registry (pull_request) Has been skipped

- Removed complex remote URL configuration logic for authentication.
- Updated comments to clarify that the remote should already be configured with the token before pushing to the main branch.
This commit is contained in:
Juan Sebastián Montoya 2025-11-26 12:52:33 -05:00
parent 7e6eb26fad
commit 96a74dbad1

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