Skip to content

Commit c492fac

Browse files
authored
fix(ci): use RELEASE_TOKEN to bypass protected branch in semantic-release (#152)
* fix(ci): use RELEASE_TOKEN to bypass protected branch in semantic-release GITHUB_TOKEN cannot push to a branch protected by PR requirement. RELEASE_TOKEN (PAT with repo scope) must be created as a repository secret and added to branch protection bypass rules. Closes #151 * fix(ci): replace RELEASE_TOKEN PAT with GitHub App token for protected branch push Uses actions/create-github-app-token to generate a short-lived token from a GitHub App that has branch protection bypass permissions. Secrets required: RELEASE_APP_ID, RELEASE_APP_PRIVATE_KEY.
1 parent eb1cdfe commit c492fac

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ jobs:
1616
if: github.repository_owner == 'OneLiteFeatherNET'
1717
runs-on: ubuntu-latest
1818
steps:
19+
- name: Generate bot token
20+
id: app-token
21+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713a63b1132f8e3a # v2
22+
with:
23+
app-id: ${{ secrets.RELEASE_APP_ID }}
24+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
25+
1926
- name: Checkout repository
2027
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2128
with:
2229
fetch-depth: 0
23-
persist-credentials: false
30+
token: ${{ steps.app-token.outputs.token }}
2431

2532
- name: Setup Java
2633
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
@@ -44,7 +51,7 @@ jobs:
4451
- name: Run semantic-release
4552
run: npx --no-install semantic-release
4653
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
4855
ONELITEFEATHER_MAVEN_USERNAME: ${{ secrets.ONELITEFEATHER_MAVEN_USERNAME }}
4956
ONELITEFEATHER_MAVEN_PASSWORD: ${{ secrets.ONELITEFEATHER_MAVEN_PASSWORD }}
5057
GIT_AUTHOR_NAME: "github-actions[bot]"

0 commit comments

Comments
 (0)