Skip to content

Commit 1a30b38

Browse files
committed
ci(steps): Handle push into protected branch
1 parent 3df8aec commit 1a30b38

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ jobs:
5353
pull-requests: write
5454
runs-on: ubuntu-latest
5555
steps:
56+
- name: 'Generate token'
57+
id: GENERATE_TOKEN
58+
uses: actions/create-github-app-token@v2
59+
with:
60+
app-id: ${{ secrets.BOT_APP_ID }}
61+
private-key: ${{ steps.decode.outputs.private-key }}
62+
63+
- name: Get GitHub App User ID
64+
id: get-user-id
65+
run: echo "user-id=$(gh api "/users/${{ steps.GENERATE_TOKEN.outputs.app-slug }}" --jq .id)" >> "$GITHUB_OUTPUT"
66+
env:
67+
GH_TOKEN: ${{ steps.GENERATE_TOKEN.outputs.token }}
68+
69+
- name: Set global username and email
70+
run: |
71+
git config --global user.name '${{ steps.GENERATE_TOKEN.outputs.app-slug }}'
72+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.GENERATE_TOKEN.outputs.app-slug }}[bot]@users.noreply.github.com'
73+
5674
- name: Checkout
5775
uses: actions/checkout@v4
5876

@@ -78,8 +96,12 @@ jobs:
7896
with:
7997
inputs: "*.tgz"
8098

99+
- name: Debug auth
100+
run: |
101+
curl -s -H "Authorization: token ${{ steps.GENERATE_TOKEN.outputs.token }}" https://api.github.com/user
102+
81103
- name: Run Semantic Release
82104
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
GITHUB_TOKEN: ${{ steps.GENERATE_TOKEN.outputs.token }}
84106
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
85107
run: npx semantic-release

0 commit comments

Comments
 (0)