chore: update CI workflow to use FORGEBOT_ACCESS_TOKEN for authentication and change git user configuration
This commit is contained in:
parent
22c16e533e
commit
e82e811025
1 changed files with 19 additions and 4 deletions
|
|
@ -50,6 +50,7 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch all history for tags
|
||||
token: ${{ secrets.FORGEBOT_ACCESS_TOKEN }}
|
||||
|
||||
- name: Login to Registry
|
||||
run: |
|
||||
|
|
@ -165,8 +166,22 @@ jobs:
|
|||
echo "📝 Updating version files to: $VERSION"
|
||||
|
||||
# Configure git
|
||||
git config user.name "forgejo-actions"
|
||||
git config user.email "forgejo-actions@forgejo.io"
|
||||
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"
|
||||
|
|
@ -198,9 +213,9 @@ jobs:
|
|||
exit 0
|
||||
}
|
||||
|
||||
# Push to main branch
|
||||
# Push to main branch using the token
|
||||
git push origin main || {
|
||||
echo "⚠️ Push failed (may need manual intervention or branch protection)"
|
||||
echo "⚠️ Push failed (check token permissions)"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue