Skip to content

Commit 0b21d65

Browse files
committed
ci: fix protected branch error in release workflow
1 parent 53336e8 commit 0b21d65

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,45 @@ name: Release
22

33
on:
44
push:
5-
branches:
6-
- main
5+
# TODO: revert
6+
# branches:
7+
# - main
78

89
concurrency:
910
group: release
1011
cancel-in-progress: false
1112

12-
permissions:
13-
contents: write
14-
id-token: write
15-
16-
env:
17-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18-
NX_NON_NATIVE_HASHER: true
19-
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
20-
2113
jobs:
2214
release:
2315
name: Publish packages
2416
runs-on: ubuntu-latest
17+
# TODO: revert
18+
# environment: release
19+
env:
20+
NX_NON_NATIVE_HASHER: true
21+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
2522
steps:
23+
- name: Authenticate as "Code PushUp Bot" GitHub App
24+
uses: actions/create-github-app-token@v2
25+
id: app-token
26+
with:
27+
app-id: ${{ vars.GH_APP_ID }}
28+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
29+
- name: Fetch GitHub App's user ID
30+
id: get-user-id
31+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
32+
env:
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
34+
- name: Configure Git user
35+
run: |
36+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
37+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
2638
- name: Clone the repository
2739
uses: actions/checkout@v4
2840
with:
2941
fetch-depth: 0
30-
- name: Configure Git user
31-
# https://github.com/actions/checkout/blob/main/README.md#push-a-commit-using-the-built-in-token
32-
run: |
33-
git config user.name github-actions[bot]
34-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
42+
token: ${{ steps.app-token.outputs.token }}
43+
persist-credentials: false
3544
- name: Set up Node.js
3645
uses: actions/setup-node@v4
3746
with:
@@ -40,4 +49,8 @@ jobs:
4049
- name: Install dependencies
4150
run: npm ci
4251
- name: Version, release and publish packages
43-
run: npx nx release --yes
52+
# TODO: revert
53+
# run: npx nx release --yes
54+
run: npx nx release publish
55+
env:
56+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)