Skip to content

Commit d11ac0d

Browse files
authored
ci: use GitHub app for ephemeral tokens (#357)
1 parent 5cd77ff commit d11ac0d

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

.github/workflows/release.yml

+19-5
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,30 @@ jobs:
110110
name: Post Release
111111
needs: release
112112
runs-on: ubuntu-latest
113-
permissions:
114-
contents: write
115-
env:
116-
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
117113
steps:
114+
- name: Get token
115+
id: get_token
116+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
117+
with:
118+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
119+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
120+
permissions: >-
121+
{
122+
"contents": "write",
123+
"pull_requests": "write"
124+
}
125+
repositories: >-
126+
["apm-agent-android"]
127+
118128
- uses: actions/checkout@v4
119129
with:
120130
ref: ${{ inputs.branch_specifier || 'main' }}
121-
token: ${{ env.GITHUB_TOKEN }}
131+
token: ${{ steps.get_token.outputs.token }}
132+
122133
- uses: elastic/oblt-actions/git/setup@v1
134+
with:
135+
github-token: ${{ steps.get_token.outputs.token }}
136+
123137
- uses: ./.github/actions/setup
124138
- if: ${{ ! inputs.dry_run }}
125139
run: ./gradlew postDeploy -Prelease=true -Pversion_override=${{ inputs.version_override_specifier || '' }}

.github/workflows/updateVersionBranch.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,36 @@ on:
99
- closed
1010

1111
permissions:
12-
contents: write
12+
contents: read
1313

1414
jobs:
1515
if_merged_postDeploy:
1616
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'post-release/')
1717
runs-on: ubuntu-latest
1818
name: Create PR to update version branch
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
2119
steps:
20+
- name: Get token
21+
id: get_token
22+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
23+
with:
24+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
25+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
26+
permissions: >-
27+
{
28+
"contents": "write",
29+
"pull_requests": "write"
30+
}
31+
repositories: >-
32+
["apm-agent-android"]
33+
2234
- uses: actions/checkout@v4
2335
with:
2436
fetch-depth: 0
37+
token: ${{ steps.get_token.outputs.token }}
2538

2639
- uses: elastic/oblt-actions/git/setup@v1
40+
with:
41+
github-token: ${{ steps.get_token.outputs.token }}
2742

2843
- uses: actions-ecosystem/action-regex-match@v2
2944
id: major-version
@@ -39,5 +54,5 @@ jobs:
3954
git push -u origin $CONFLICT_RESOLUTION_BRANCH
4055
gh pr create --base ${{ env.BASE_BRANCH }} --title 'Merge main into version branch' --body 'Created by Github action :robot:' --reviewer elastic/apm-agent-android
4156
env:
42-
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
57+
GH_TOKEN: ${{ steps.get_token.outputs.token }}
4358
BASE_BRANCH: "${{ steps.major-version.outputs.group1 }}.x"

0 commit comments

Comments
 (0)