Skip to content

Commit f940451

Browse files
authored
github-actions: use ephemeral tokens for add the different projects board (#561)
1 parent d48c671 commit f940451

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

.github/workflows/addToAPMProject.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ jobs:
1010
add_to_project:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Get token
14+
id: get_token
15+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
16+
with:
17+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
18+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
19+
permissions: >-
20+
{
21+
"organization_projects": "write",
22+
"issues": "read"
23+
}
1324
- uses: octokit/[email protected]
1425
id: add_to_project
1526
with:
@@ -27,7 +38,7 @@ jobs:
2738
contentid: ${{ github.event.issue.node_id }}
2839
env:
2940
PROJECT_ID: "PVT_kwDOAGc3Zs0VSg"
30-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
41+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3142
- uses: octokit/[email protected]
3243
id: label_team
3344
with:
@@ -50,4 +61,4 @@ jobs:
5061
value: "6c538d8a"
5162
env:
5263
PROJECT_ID: "PVT_kwDOAGc3Zs0VSg"
53-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
64+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

.github/workflows/addToDocsProject.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: github.event.label.name == 'Team:Docs'
1313
steps:
14+
- name: Get token
15+
id: get_token
16+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
17+
with:
18+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
19+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
20+
permissions: >-
21+
{
22+
"organization_projects": "write",
23+
"issues": "read"
24+
}
1425
- uses: octokit/[email protected]
1526
id: add_to_project
1627
with:
@@ -28,4 +39,4 @@ jobs:
2839
contentid: ${{ github.event.issue.node_id }}
2940
env:
3041
PROJECT_ID: "PVT_kwDOAGc3Zs0iZw"
31-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
42+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

.github/workflows/labeler.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
types: [opened]
55
pull_request_target:
66
types: [opened]
7-
env:
8-
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
97

108
permissions:
119
contents: read
@@ -16,6 +14,18 @@ jobs:
1614
triage:
1715
runs-on: ubuntu-latest
1816
steps:
17+
- name: Get token
18+
id: get_token
19+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
20+
with:
21+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
22+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
23+
permissions: >-
24+
{
25+
"members": "read",
26+
"organization_projects": "write",
27+
"issues": "read"
28+
}
1929
- name: Add aws-λ-extension label
2030
uses: github/[email protected]
2131
with:
@@ -31,7 +41,7 @@ jobs:
3141
usernamesToExclude: |
3242
apmmachine
3343
dependabot
34-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
44+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3545
- name: Show team membership
3646
run: |
3747
echo "::debug::isTeamMember: ${{ steps.checkUserMember.outputs.isTeamMember }}"
@@ -50,3 +60,5 @@ jobs:
5060
project: 'https://github.com/orgs/elastic/projects/454'
5161
project_id: '5882982'
5262
column_name: 'In Progress'
63+
env:
64+
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

0 commit comments

Comments
 (0)