Skip to content

Commit f0468ee

Browse files
mergify[bot]v1v
andauthored
[7.17] github-action: use ephemeral tokens with the required permissions (backport #14010) (#14102)
* github-action: use ephemeral tokens with the required permissions (#14010) (cherry picked from commit abb9a9b) # Conflicts: # .github/workflows/update-compose.yml * Apply suggestions from code review --------- Co-authored-by: Victor Martinez <[email protected]>
1 parent 3812d5d commit f0468ee

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
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

@@ -62,7 +74,7 @@ jobs:
6274
with:
6375
command: --experimental apply --config .ci/updatecli/bump-golang.yml --values .ci/updatecli/values.d/scm.yml
6476
env:
65-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
77+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6678
GITHUB_BRANCH: '7.17'
6779
GITHUB_LABELS: 'backport-skip'
6880

.github/workflows/update-beats.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ 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: actions/setup-go@v5
3446
with:
3547
go-version-file: go.mod
@@ -39,7 +51,7 @@ jobs:
3951
command: --experimental apply --config .ci/updatecli/update-beats.yml --values .ci/updatecli/values.d/scm.yml
4052
env:
4153
BRANCH_NAME: ${{ matrix.branch }}
42-
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
54+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
4355

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

.github/workflows/update-compose.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
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+
33+
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
2234
with:
2335
registry: ghcr.io
2436
username: ${{ github.actor }}
@@ -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)