Hotfix/Fix push version update #8

Merged
jusemon merged 1 commit from hotfix/fix-push-version-update into main 2025-11-26 11:58:12 -05:00

View file

@ -50,6 +50,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Fetch all history for tags fetch-depth: 0 # Fetch all history for tags
token: ${{ secrets.FORGEBOT_ACCESS_TOKEN }}
- name: Login to Registry - name: Login to Registry
run: | run: |
@ -165,8 +166,22 @@ jobs:
echo "📝 Updating version files to: $VERSION" echo "📝 Updating version files to: $VERSION"
# Configure git # Configure git
git config user.name "forgejo-actions" git config user.name "forgebot"
git config user.email "forgejo-actions@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"
@ -198,9 +213,9 @@ jobs:
exit 0 exit 0
} }
# Push to main branch # Push to main branch using the token
git push origin main || { git push origin main || {
echo "⚠️ Push failed (may need manual intervention or branch protection)" echo "⚠️ Push failed (check token permissions)"
exit 0 exit 0
} }