@@ -249,6 +249,7 @@ For this purpose a token must be created with the following scope as depicted in
249249 
250250
251251example workflow definition
252+ :warning : to the checkout action you need to add the parameter `persist-credentials: false` or you will most likely face an issue (#557 # 627)
252253
253254` ` ` yml
254255name: actions-template-sync
@@ -272,6 +273,7 @@ jobs:
272273 with:
273274 # submodules: true
274275 token: ${{ secrets.CUSTOM_GITHUB_PAT }}
276+ persist-credentials: false # needed see #557 and #627
275277
276278 - name: Test action step PAT
277279 uses: AndreasAugustin/actions-template-sync@v2
@@ -659,48 +661,51 @@ The idea is to use the [docker action][action-docker]
659661is indicating that the PAT in the `target_gh_token` does not have the correct permissions.
660662This happens because the template repository is trying to overwrite some files inside `.github/workflows/`.
661663
662- Currently `GITHUB_TOKEN` can't be given `workflow` permission.
663- You can grant our workflow with `workflow` permission using a PAT following the steps below :
664-
665- 1. [Create a PAT][github-create-pat] with these repository permissions granted : ` workflow` .
666-
667- 2. Copy the generated token and [create a new secret for your target repository][github-create-secret].
668-
669- 3. Configure the `actions-template-sync` step to use the freshly generated token in `target_gh_token` like this :
670-
671- ` ` ` yaml
672- # File: .github/workflows/template-sync.yml
673-
674- on:
675- # cronjob trigger
676- schedule:
677- - cron: "0 0 1 * *"
678- # manual trigger
679- workflow_dispatch:
680- jobs:
681- repo-sync:
682- runs-on: ubuntu-latest
683- # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
684- permissions:
685- contents: write
686- pull-requests: write
687-
688- steps:
689- # To use this repository's private action, you must check out the repository
690- - name: Checkout
691- uses: actions/checkout@v4
692- with:
693- # submodules: true
694-
695- - name: actions-template-sync
696- uses: AndreasAugustin/actions-template-sync@v2
697- with:
698- source_gh_token: ${{ secrets.GITHUB_TOKEN }}
699- target_gh_token: ${{ secrets.<secret_name> }}
700- source_repo_path: <owner/repo>
701- upstream_branch: <target_branch> # defaults to main
702- pr_labels: <label1>,<label2>[,...] # optional, no default
703- ` ` `
664+ Currently `GITHUB_TOKEN` can't be given `workflow` permission.
665+ You can grant our workflow with `workflow` permission using a PAT following the steps below :
666+
667+ 1. [Create a PAT][github-create-pat] with these repository permissions granted : ` workflow` .
668+
669+ 2. Copy the generated token and [create a new secret for your target repository][github-create-secret].
670+
671+ 3. Configure the `actions-template-sync` step to use the freshly generated token in `target_gh_token` like this :
672+
673+ ` ` ` yaml
674+ # File: .github/workflows/template-sync.yml
675+
676+ on:
677+ # cronjob trigger
678+ schedule:
679+ - cron: "0 0 1 * *"
680+ # manual trigger
681+ workflow_dispatch:
682+ jobs:
683+ repo-sync:
684+ runs-on: ubuntu-latest
685+ # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
686+ permissions:
687+ contents: write
688+ pull-requests: write
689+
690+ steps:
691+ # To use this repository's private action, you must check out the repository
692+ - name: Checkout
693+ uses: actions/checkout@v4
694+ with:
695+ # submodules: true
696+ persist-credentials: false # needed
697+
698+ - name: actions-template-sync
699+ uses: AndreasAugustin/actions-template-sync@v2
700+ with:
701+ source_gh_token: ${{ secrets.GITHUB_TOKEN }}
702+ target_gh_token: ${{ secrets.<secret_name> }}
703+ source_repo_path: <owner/repo>
704+ upstream_branch: <target_branch> # defaults to main
705+ pr_labels: <label1>,<label2>[,...] # optional, no default
706+ ` ` `
707+
708+ :warning : you need to add `persist-credentials: false` to the checkout action
704709
705710* pull request create failed: GraphQL: GitHub Actions is not permitted to create or approve pull requests (createPullRequest)
706711
0 commit comments