Skip to content

Commit 8249dcc

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

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI Pipeline
2+
run-name: ${{ github.actor }} is automatically publishing
23

34
on:
45
push:
@@ -53,6 +54,30 @@ jobs:
5354
pull-requests: write
5455
runs-on: ubuntu-latest
5556
steps:
57+
- name: 'Generate token'
58+
id: GENERATE_TOKEN
59+
uses: actions/create-github-app-token@v2
60+
with:
61+
app-id: ${{ secrets.BOT_APP_ID }}
62+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
63+
64+
- name: Get GitHub App User ID
65+
id: get-user-id
66+
run: |
67+
echo "user-id=$(gh api "/users/${{ steps.GENERATE_TOKEN.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
68+
echo ${{ steps.GENERATE_TOKEN.outputs.token }}
69+
env:
70+
GH_TOKEN: ${{ steps.GENERATE_TOKEN.outputs.token }}
71+
72+
- name: Set global username and email
73+
run: |
74+
git config --global user.name '${{ steps.GENERATE_TOKEN.outputs.app-slug }}[bot]'
75+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.GENERATE_TOKEN.outputs.app-slug }}[bot]@users.noreply.github.com'
76+
77+
- name: Debug auth
78+
run: |
79+
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ steps.GENERATE_TOKEN.outputs.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/user
80+
5681
- name: Checkout
5782
uses: actions/checkout@v4
5883

@@ -80,6 +105,6 @@ jobs:
80105

81106
- name: Run Semantic Release
82107
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
GITHUB_TOKEN: ${{ steps.GENERATE_TOKEN.outputs.token }}
84109
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
85110
run: npx semantic-release

0 commit comments

Comments
 (0)