Refactor CI workflow to simplify remote URL configuration #10
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