Skip to content

Commit e5a55ec

Browse files
Update template_update.yml
1 parent 92d5662 commit e5a55ec

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/template_update.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)