Refactor CI workflow to simplify remote URL configuration (#10)
- 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. Reviewed-on: #10 Co-authored-by: Juan Sebastian Montoya <juansmm@outlook.com> Co-committed-by: Juan Sebastian Montoya <juansmm@outlook.com>
This commit is contained in:
parent
7e6eb26fad
commit
9adb60d244
1 changed files with 1 additions and 15 deletions
|
|
@ -187,20 +187,6 @@ jobs:
|
||||||
git config user.name "forgebot"
|
git config user.name "forgebot"
|
||||||
git config user.email "forgebot@forgejo.io"
|
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
|
# Fetch latest changes to avoid conflicts
|
||||||
git fetch origin main || echo "Fetch completed or already up to date"
|
git fetch origin main || echo "Fetch completed or already up to date"
|
||||||
git checkout main || echo "Already on main"
|
git checkout main || echo "Already on main"
|
||||||
|
|
@ -231,7 +217,7 @@ jobs:
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Push to main branch using the token
|
# Push to main branch (remote should already be configured with token)
|
||||||
git push origin main || {
|
git push origin main || {
|
||||||
echo "⚠️ Push failed (check token permissions)"
|
echo "⚠️ Push failed (check token permissions)"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue