Skip to content

Commit c467743

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

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,44 @@ 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+
environment: release
18+
env:
19+
NX_NON_NATIVE_HASHER: true
20+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
2521
steps:
22+
- name: Authenticate as "Code PushUp Bot" GitHub App
23+
uses: actions/create-github-app-token@v2
24+
id: app-token
25+
with:
26+
app-id: ${{ vars.GH_APP_ID }}
27+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
28+
- name: Fetch GitHub App's user ID
29+
id: get-user-id
30+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
31+
env:
32+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
33+
- name: Configure Git user
34+
run: |
35+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
36+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
2637
- name: Clone the repository
2738
uses: actions/checkout@v4
2839
with:
2940
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
41+
token: ${{ steps.app-token.outputs.token }}
42+
persist-credentials: false
3543
- name: Set up Node.js
3644
uses: actions/setup-node@v4
3745
with:
@@ -40,4 +48,8 @@ jobs:
4048
- name: Install dependencies
4149
run: npm ci
4250
- name: Version, release and publish packages
43-
run: npx nx release --yes
51+
# TODO: revert
52+
# run: npx nx release --yes
53+
run: npx nx release publish
54+
env:
55+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)