Skip to content

Commit 5ae9582

Browse files
mergify[bot]v1v
andauthored
github-action: use ephemeral tokens with the required permissions (#14010) (#14104)
(cherry picked from commit abb9a9b) Co-authored-by: Victor Martinez <[email protected]>
1 parent 1fcfc92 commit 5ae9582

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

.github/workflows/bump-elastic-stack.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,24 @@ jobs:
3030
with:
3131
ref: ${{ matrix.branch }}
3232

33+
- name: Get token
34+
id: get_token
35+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
36+
with:
37+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
38+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
39+
permissions: >-
40+
{
41+
"contents": "write",
42+
"pull_requests": "write"
43+
}
44+
3345
- uses: elastic/oblt-actions/updatecli/run@v1
3446
with:
3547
command: --experimental apply --config .ci/updatecli/bump-elastic-stack-snapshot.yml --values .ci/updatecli/values.d/scm.yml
3648
env:
3749
BRANCH: ${{ matrix.branch }}
38-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
50+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3951

4052
- if: ${{ failure() }}
4153
uses: elastic/oblt-actions/slack/send@v1

.github/workflows/bump-golang.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,23 @@ jobs:
4141

4242
- uses: actions/checkout@v4
4343

44+
- name: Get token
45+
id: get_token
46+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
47+
with:
48+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
49+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
50+
permissions: >-
51+
{
52+
"contents": "write",
53+
"pull_requests": "write"
54+
}
55+
4456
- uses: elastic/oblt-actions/updatecli/run@v1
4557
with:
4658
command: --experimental apply --config .ci/updatecli/bump-golang.yml --values .ci/updatecli/values.d/scm.yml
4759
env:
48-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
60+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
4961
GITHUB_BRANCH: 'main'
5062
GITHUB_LABELS: ${{ needs.labels.outputs.backports }}
5163

@@ -60,7 +72,7 @@ jobs:
6072
with:
6173
command: --experimental apply --config .ci/updatecli/bump-golang.yml --values .ci/updatecli/values.d/scm.yml
6274
env:
63-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
75+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6476
GITHUB_BRANCH: '7.17'
6577
GITHUB_LABELS: 'backport-skip'
6678

.github/workflows/update-beats.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ jobs:
2929
with:
3030
ref: ${{ matrix.branch }}
3131

32+
- name: Get token
33+
id: get_token
34+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
35+
with:
36+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
37+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
38+
permissions: >-
39+
{
40+
"contents": "write",
41+
"pull_requests": "write"
42+
}
43+
3244
- uses: actions/setup-go@v5
3345
with:
3446
go-version-file: go.mod
@@ -38,7 +50,7 @@ jobs:
3850
command: --experimental apply --config .ci/updatecli/update-beats.yml --values .ci/updatecli/values.d/scm.yml
3951
env:
4052
BRANCH_NAME: ${{ matrix.branch }}
41-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
53+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
4254

4355
- if: ${{ failure() }}
4456
uses: elastic/oblt-actions/slack/send@v1

.github/workflows/update-compose.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020

21+
- name: Get token
22+
id: get_token
23+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
24+
with:
25+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
26+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
27+
permissions: >-
28+
{
29+
"contents": "write",
30+
"pull_requests": "write"
31+
}
32+
2133
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
2234
with:
2335
registry: ghcr.io
@@ -28,13 +40,13 @@ jobs:
2840
with:
2941
command: --experimental compose diff
3042
env:
31-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
43+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3244

3345
- uses: elastic/oblt-actions/updatecli/run@v1
3446
with:
3547
command: --experimental compose apply
3648
env:
37-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
49+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3850

3951
- if: ${{ failure() }}
4052
uses: elastic/oblt-actions/slack/send@v1

0 commit comments

Comments
 (0)