@@ -28,12 +28,29 @@ jobs:
2828 persist-credentials : false
2929
3030 - name : Sync repo to branch
31- uses : repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88
32- with :
33- source_repo : https://${{ secrets.DOCS_BOT_PAT_REPO_SYNC }}@github.com/github/${{ github.repository == 'github/docs-internal' && 'docs' || 'docs-internal' }}.git
34- source_branch : main
35- destination_branch : repo-sync
36- github_token : ${{ secrets.DOCS_BOT_PAT_REPO_SYNC }}
31+ env :
32+ SOURCE_REPO : https://${{ secrets.DOCS_BOT_PAT_REPO_SYNC }}@github.com/github/${{ github.repository == 'github/docs-internal' && 'docs' || 'docs-internal' }}.git
33+ SOURCE_BRANCH : main
34+ DESTINATION_BRANCH : repo-sync
35+ GH_TOKEN : ${{ secrets.DOCS_BOT_PAT_REPO_SYNC }}
36+ run : |
37+ set -euo pipefail
38+
39+ : "${GH_TOKEN:?DOCS_BOT_PAT_REPO_SYNC is empty}"
40+ : "${SOURCE_REPO:?SOURCE_REPO is empty}"
41+ : "${SOURCE_BRANCH:?SOURCE_BRANCH is empty}"
42+ : "${DESTINATION_BRANCH:?DESTINATION_BRANCH is empty}"
43+
44+ git config --unset-all http."https://github.com/".extraheader || true
45+
46+ git remote remove tmp_upstream 2>/dev/null || true
47+ trap 'git remote remove tmp_upstream 2>/dev/null || true' EXIT
48+
49+ git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
50+ git remote add tmp_upstream "${SOURCE_REPO}"
51+
52+ git fetch tmp_upstream --quiet
53+ git push origin "refs/remotes/tmp_upstream/${SOURCE_BRANCH}:refs/heads/${DESTINATION_BRANCH}" --force
3754
3855 - name : Ship pull request
3956 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
0 commit comments