Skip to content

Commit 64063fd

Browse files
committed
ci: use GitHub app for ephemeral tokens
1 parent 9a12b98 commit 64063fd

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

.github/workflows/pre-post-release.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,29 @@ jobs:
5353
runs-on: ubuntu-latest
5454
needs:
5555
- validate-tag
56-
permissions:
57-
contents: write
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
6056
steps:
57+
- name: Get token
58+
id: get_token
59+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
60+
with:
61+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
62+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
63+
permissions: >-
64+
{
65+
"contents": "write",
66+
"pull_requests": "write"
67+
}
68+
repositories: >-
69+
["${{github.repository}}"]
70+
6171
- uses: actions/checkout@v4
6272
with:
6373
ref: ${{ inputs.ref }}
64-
token: ${{ env.GITHUB_TOKEN }}
74+
token: ${{ steps.get_token.outputs.token }}
6575

6676
- uses: elastic/oblt-actions/git/setup@v1
77+
with:
78+
github-token: ${{ steps.get_token.outputs.token }}
6779

6880
- name: Create the release tag (post phase)
6981
if: inputs.phase == 'post'
@@ -95,4 +107,4 @@ jobs:
95107
- name: Create the ${{ inputs.phase }} release PR
96108
run: gh pr create --title="${{ inputs.pr_title }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.pr_body }}"
97109
env:
98-
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
110+
GH_TOKEN: ${{ steps.get_token.outputs.token }}

.github/workflows/release-step-3.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,28 @@ jobs:
213213
runs-on: ubuntu-latest
214214
needs:
215215
- post-release
216-
permissions:
217-
contents: write
218-
env:
219-
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
220216
steps:
217+
- name: Get token
218+
id: get_token
219+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
220+
with:
221+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
222+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
223+
permissions: >-
224+
{
225+
"contents": "write"
226+
}
227+
repositories: >-
228+
["${{github.repository}}"]
229+
221230
- uses: actions/checkout@v4
222231
with:
223232
ref: ${{ inputs.ref }}
224-
token: ${{ env.GITHUB_TOKEN }}
233+
token: ${{ steps.get_token.outputs.token }}
225234

226235
- uses: elastic/oblt-actions/git/setup@v1
236+
with:
237+
github-token: ${{ steps.get_token.outputs.token }}
227238

228239
- name: Update major branch
229240
if: ${{ ! inputs.dry_run }}

0 commit comments

Comments
 (0)