Skip to content

Commit 19a3a85

Browse files
committed
fix(release): use app token for actions/checkout
Since the release performs `git` commands, we have to ensure they are also done using the app token, otherwise we won't have permission to bypass branch protections or update workflows files. For most release steps, the combination of `persist-credentials:false`, and passing the right `GITHUB_TOKEN` to the semantic-release action ensures this, but it appears `@semantic-release/git` simply calls `git` commands within our checkout, which implicitly uses the original token, so it fails: remote: error: GH013: Repository rule violations found for refs/heads/main. remote: Review all repository rules at https://github.com/freckle/stack-action/rules?ref=refs%2Fheads%2Fmain remote: remote: - Changes must be made through a pull request. remote: remote: - 3 of 3 required status checks are expected. remote: To https://github.com/freckle/stack-action.git ! [remote rejected] HEAD -> main (push declined due to repository rule violations) To fix this, we pass the app token to `actions/checkout` too. At that point, there's no reason not to persist them, since it's the correct token we'd always want to use, so I removed that too.
1 parent dd33adc commit 19a3a85

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
release:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
15-
with:
16-
persist-credentials: false
17-
1814
- id: token
1915
uses: actions/create-github-app-token@v2
2016
with:
2117
app-id: ${{ vars.FRECKLE_AUTOMATION_APP_ID }}
2218
private-key: ${{ secrets.FRECKLE_AUTOMATION_PRIVATE_KEY }}
2319

20+
- uses: actions/checkout@v4
21+
with:
22+
token: ${{ steps.token.outputs.token }}
23+
2424
- id: release
2525
uses: cycjimmy/semantic-release-action@v4
2626
with:

0 commit comments

Comments
 (0)