Skip to content

Commit d804694

Browse files
committed
Use secure-checkout action to generate token and run checkout
1 parent af09ea9 commit d804694

File tree

2 files changed

+16
-53
lines changed

2 files changed

+16
-53
lines changed

.github/workflows/package-release.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,11 @@ jobs:
1818
id-token: write
1919

2020
steps:
21-
- name: "Create temporary app token"
22-
uses: actions/create-github-app-token@v1
23-
id: app-token
21+
- name: "Generate token and checkout repository"
22+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
2423
with:
25-
app-id: ${{ vars.APP_ID }}
26-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
27-
28-
- name: "Store GitHub token in environment"
29-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
30-
shell: bash
31-
32-
- name: "Checkout"
33-
uses: "actions/checkout@v4"
34-
with:
35-
# Manually specify a ref. When actions/checkout is run for a tag without a ref, it looks up the underlying
36-
# commit and specifically fetches this to the refs/tags/<tag> ref, which denies us access to the tag message
24+
app_id: ${{ vars.APP_ID }}
25+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
3726
ref: ${{ inputs.ref }}
3827
submodules: true
3928

@@ -159,19 +148,11 @@ jobs:
159148
ts: [ ts, nts ]
160149

161150
steps:
162-
- name: "Create temporary app token"
163-
uses: actions/create-github-app-token@v1
164-
id: app-token
165-
with:
166-
app-id: ${{ vars.APP_ID }}
167-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
168-
169-
- name: "Store GitHub token in environment"
170-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
171-
shell: bash
172-
173-
- uses: actions/checkout@v4
151+
- name: "Generate token and checkout repository"
152+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
174153
with:
154+
app_id: ${{ vars.APP_ID }}
155+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
175156
ref: ${{ inputs.ref }}
176157

177158
- name: "Set up drivers-github-tools"

.github/workflows/release.yml

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,12 @@ jobs:
5656
- name: "Create release output"
5757
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
5858

59-
- name: "Create temporary app token"
60-
uses: actions/create-github-app-token@v1
61-
id: app-token
62-
with:
63-
app-id: ${{ vars.APP_ID }}
64-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
65-
66-
- name: "Store GitHub token in environment"
67-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
68-
shell: bash
69-
70-
- uses: actions/checkout@v4
59+
- name: "Generate token and checkout repository"
60+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
7161
with:
62+
app_id: ${{ vars.APP_ID }}
63+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
7264
submodules: true
73-
token: ${{ env.GH_TOKEN }}
7465

7566
- name: "Set up drivers-github-tools"
7667
uses: mongodb-labs/drivers-github-tools/setup@v2
@@ -196,21 +187,12 @@ jobs:
196187
contents: write
197188

198189
steps:
199-
- name: "Create temporary app token"
200-
uses: actions/create-github-app-token@v1
201-
id: app-token
202-
with:
203-
app-id: ${{ vars.APP_ID }}
204-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
205-
206-
- name: "Store GitHub token in environment"
207-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
208-
shell: bash
209-
210-
- uses: actions/checkout@v4
190+
- name: "Generate token and checkout repository"
191+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
211192
with:
193+
app_id: ${{ vars.APP_ID }}
194+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
212195
ref: refs/tags/${{ inputs.version }}
213-
token: ${{ env.GH_TOKEN }}
214196

215197
# Sets the S3_ASSETS environment variable used later
216198
- name: "Set up drivers-github-tools"

0 commit comments

Comments
 (0)