Skip to content

Commit 16c3114

Browse files
committed
chore: remove GH_PAT usage and NPM_TOKEN
All npm publishing must be done through Trusted Publisher. GH_PAT should not be used and a dedicated GitHub app with tightly scoped permissions is to be used instead.
1 parent 554656f commit 16c3114

File tree

5 files changed

+59
-12
lines changed

5 files changed

+59
-12
lines changed

.github/workflows/api-sync.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
id: cpr
4242
uses: peter-evans/create-pull-request@v7
4343
with:
44-
token: ${{ secrets.GH_PAT }}
4544
commit-message: "chore: sync API types from infrastructure"
4645
title: "chore: sync API types from infrastructure"
4746
body: |
@@ -58,4 +57,4 @@ jobs:
5857
if: steps.check.outputs.has_changes == 'true'
5958
run: gh pr merge --auto --squash "${{ steps.cpr.outputs.pull-request-number }}"
6059
env:
61-
GH_TOKEN: ${{ secrets.GH_PAT }}
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/automerge.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ jobs:
2222
with:
2323
github-token: "${{ secrets.GITHUB_TOKEN }}"
2424

25+
- name: Generate token
26+
id: app-token
27+
uses: actions/create-github-app-token@v2
28+
with:
29+
app-id: ${{ secrets.APP_ID }}
30+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
2531
# Here the PR gets approved.
2632
- name: Approve a PR
2733
if: ${{ steps.meta.outputs.update-type == 'version-update:semver-patch' || (!startsWith(steps.meta.outputs.previous-version, '0.') && steps.meta.outputs.update-type == 'version-update:semver-minor') }}
2834
run: gh pr review --approve "${{ github.event.pull_request.html_url }}"
2935
env:
30-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
36+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
3137

3238
# Finally, this sets the PR to allow auto-merging for patch and minor
3339
# updates if all checks pass
3440
- name: Enable auto-merge for Dependabot PRs
3541
if: ${{ steps.meta.outputs.update-type == 'version-update:semver-patch' || (!startsWith(steps.meta.outputs.previous-version, '0.') && steps.meta.outputs.update-type == 'version-update:semver-minor') }}
3642
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
3743
env:
38-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
44+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/release-beta.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
permissions:
1010
contents: write
11+
id-token: write
1112

1213
jobs:
1314
release:
@@ -65,14 +66,21 @@ jobs:
6566
if: needs.release.outputs.new-release-published == 'true'
6667
runs-on: ubuntu-latest
6768
steps:
69+
# use GitHub app to create a release token that can publish to homebrew-tap and scoop
70+
- name: Generate token
71+
id: app-token
72+
uses: actions/create-github-app-token@v2
73+
with:
74+
app-id: ${{ secrets.APP_ID }}
75+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
6876
- uses: actions/checkout@v6
6977
- uses: actions/setup-go@v6
7078
with:
7179
go-version-file: go.mod
7280
cache: true
7381
- run: go run tools/publish/main.go --beta "${{ needs.release.outputs.new-release-version }}"
7482
env:
75-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
83+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
7684

7785
publish:
7886
name: Publish NPM
@@ -87,7 +95,10 @@ jobs:
8795
with:
8896
node-version: "16.x"
8997
registry-url: "https://registry.npmjs.org"
98+
99+
# Ensure npm 11.5.1 or later is installed for trusted publishing support
100+
- name: Update npm
101+
run: npm install -g npm@latest
102+
90103
- run: npm --git-tag-version=false version ${{ needs.release.outputs.new-release-version }}
91104
- run: npm publish --tag ${{ needs.release.outputs.new-release-channel }}
92-
env:
93-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
permissions:
1010
contents: write
1111
packages: write
12+
id-token: write
1213

1314
jobs:
1415
settings:
@@ -31,14 +32,21 @@ jobs:
3132
- settings
3233
runs-on: ubuntu-latest
3334
steps:
35+
# use GitHub app to create a release token that can publish to homebrew-tap and scoop
36+
- name: Generate token
37+
id: app-token
38+
uses: actions/create-github-app-token@v2
39+
with:
40+
app-id: ${{ secrets.APP_ID }}
41+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
3442
- uses: actions/checkout@v6
3543
- uses: actions/setup-go@v6
3644
with:
3745
go-version-file: go.mod
3846
cache: true
3947
- run: go run tools/publish/main.go ${{ needs.settings.outputs.release_tag }}
4048
env:
41-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
49+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
4250

4351
publish:
4452
name: Publish NPM
@@ -53,14 +61,20 @@ jobs:
5361
name: Bump self-hosted versions
5462
runs-on: ubuntu-latest
5563
steps:
64+
- name: Generate token
65+
id: app-token
66+
uses: actions/create-github-app-token@v2
67+
with:
68+
app-id: ${{ secrets.APP_ID }}
69+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
5670
- uses: actions/checkout@v6
5771
- uses: actions/setup-go@v6
5872
with:
5973
go-version-file: go.mod
6074
cache: true
6175
- run: go run tools/selfhost/main.go
6276
env:
63-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
77+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
6478

6579
changelog:
6680
name: Publish changelog
@@ -69,14 +83,20 @@ jobs:
6983
- publish
7084
runs-on: ubuntu-latest
7185
steps:
86+
- name: Generate token
87+
id: app-token
88+
uses: actions/create-github-app-token@v2
89+
with:
90+
app-id: ${{ secrets.APP_ID }}
91+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
7292
- uses: actions/checkout@v6
7393
- uses: actions/setup-go@v6
7494
with:
7595
go-version-file: go.mod
7696
cache: true
7797
- run: go run tools/changelog/main.go ${{ secrets.SLACK_CHANNEL }}
7898
env:
79-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
99+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
80100
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
81101

82102
docs:
@@ -85,11 +105,17 @@ jobs:
85105
- settings
86106
runs-on: ubuntu-latest
87107
steps:
108+
- name: Generate token
109+
id: app-token
110+
uses: actions/create-github-app-token@v2
111+
with:
112+
app-id: ${{ secrets.APP_ID }}
113+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
88114
- uses: actions/checkout@v6
89115
- uses: actions/setup-go@v6
90116
with:
91117
go-version-file: go.mod
92118
cache: true
93119
- run: go run docs/main.go ${{ needs.settings.outputs.release_tag }} | go run tools/bumpdoc/main.go apps/docs/spec/cli_v1_commands.yaml
94120
env:
95-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
121+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/tag-npm.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515

1616
permissions:
1717
contents: read
18+
id-token: write
1819

1920
jobs:
2021
tag:
@@ -26,7 +27,11 @@ jobs:
2627
with:
2728
node-version: "16.x"
2829
registry-url: "https://registry.npmjs.org"
30+
31+
# Ensure npm 11.5.1 or later is installed for trusted publishing support
32+
- name: Update npm
33+
run: npm install -g npm@latest
34+
2935
- run: npm dist-tag add "supabase@${RELEASE_TAG#v}" latest
3036
env:
3137
RELEASE_TAG: ${{ inputs.release }}
32-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)