File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,8 +121,8 @@ jobs:
121121 git config user.name "GitHub Actions Bot"
122122 git config user.email "actions@github.com"
123123
124- # Configure git to use the token for authentication
125- git config url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
124+ # Save remote URL before any operations
125+ REMOTE_URL=$( git remote get-url origin)
126126
127127 # Save current branch name
128128 CURRENT_BRANCH="${{ inputs.repo_branch }}"
@@ -160,6 +160,14 @@ jobs:
160160 git commit -m "chore: update from template ${OLD_SHA} → ${NEW_SHA} (with conflicts)"
161161 fi
162162
163+ # Ensure remote is set (may have been lost)
164+ if ! git remote get-url origin >/dev/null 2>&1; then
165+ git remote add origin "$REMOTE_URL"
166+ fi
167+
168+ # Configure authentication for push
169+ git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
170+
163171 git push origin "$BRANCH"
164172 echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
165173
You can’t perform that action at this time.
0 commit comments