ci: authenticate git push in daily branch workflows

The zizmor remediation in PR #24663 added 'persist-credentials: false'
to the checkout step but the workflow still relies on 'git push origin'
inheriting credentials from the global git config. Without persisted
credentials, the push fails with 'could not read Username for github.com'
and the scheduled job has been failing every run since.

Push directly to the authenticated HTTPS URL using GITHUB_TOKEN so the
checkout step can keep persist-credentials disabled (no token in git
config) while the push still works.

Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-06-06 16:05:28 +00:00
parent 22186f457a
commit 22284b1ade
No known key found for this signature in database
2 changed files with 3 additions and 9 deletions

View file

@ -39,9 +39,7 @@ jobs:
echo "Branch $BRANCH_NAME already exists. Skipping creation."
else
echo "Creating new branch: $BRANCH_NAME"
# Create the new branch from main
git checkout -b $BRANCH_NAME origin/main
# Push the new branch
git push origin $BRANCH_NAME
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH_NAME"
echo "Successfully created and pushed branch: $BRANCH_NAME"
fi

View file

@ -39,10 +39,8 @@ jobs:
echo "Branch $BRANCH_NAME already exists. Skipping creation."
else
echo "Creating new branch: $BRANCH_NAME"
# Create the new branch from main
git checkout -b $BRANCH_NAME origin/main
# Push the new branch
git push origin $BRANCH_NAME
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH_NAME"
echo "Successfully created and pushed branch: $BRANCH_NAME"
fi
@ -79,9 +77,7 @@ jobs:
echo "Branch $BRANCH_NAME already exists. Skipping creation."
else
echo "Creating new branch: $BRANCH_NAME"
# Create the new branch from main
git checkout -b $BRANCH_NAME origin/main
# Push the new branch
git push origin $BRANCH_NAME
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH_NAME"
echo "Successfully created and pushed branch: $BRANCH_NAME"
fi