Skip to content

Commit

Permalink
[8.15] github-action: use ephemeral tokens with the required permissi…
Browse files Browse the repository at this point in the history
…ons (backport #14010) (#14103)

* github-action: use ephemeral tokens with the required permissions (#14010)

(cherry picked from commit abb9a9b)

# Conflicts:
#	.github/workflows/bump-golang.yml
#	.github/workflows/update-compose.yml

* Apply suggestions from code review

---------

Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
  • Loading branch information
mergify[bot] and v1v authored Sep 17, 2024
1 parent 170f9da commit f75b3e0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/bump-elastic-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ jobs:
with:
ref: ${{ matrix.branch }}

- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
- uses: elastic/oblt-actions/updatecli/run@v1
with:
command: --experimental apply --config .ci/updatecli/bump-elastic-stack-snapshot.yml --values .ci/updatecli/values.d/scm.yml
env:
BRANCH: ${{ matrix.branch }}
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ jobs:

- uses: actions/checkout@v4

- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
- uses: elastic/oblt-actions/updatecli/run@v1
with:
command: --experimental apply --config .ci/updatecli/bump-golang.yml --values .ci/updatecli/values.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
GITHUB_BRANCH: 'main'
GITHUB_LABELS: ${{ needs.labels.outputs.backports }}

bump-7:
runs-on: ubuntu-latest
Expand All @@ -33,7 +47,7 @@ jobs:
with:
command: --experimental apply --config .ci/updatecli/bump-golang.yml --values .ci/updatecli/values.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
GITHUB_BRANCH: '7.17'
GITHUB_LABELS: 'backport-skip'

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/update-beats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ jobs:
with:
ref: ${{ matrix.branch }}

- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
Expand All @@ -38,7 +50,7 @@ jobs:
command: --experimental apply --config .ci/updatecli/update-beats.yml --values .ci/updatecli/values.d/scm.yml
env:
BRANCH_NAME: ${{ matrix.branch }}
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/update-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"contents": "write",
"pull_requests": "write"
}
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -28,13 +40,13 @@ jobs:
with:
command: --experimental compose diff
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

- uses: elastic/oblt-actions/updatecli/run@v1
with:
command: --experimental compose apply
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

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

0 comments on commit f75b3e0

Please sign in to comment.