Skip to content

Commit 7ff2b43

Browse files
authored
github-actions: use ephemeral tokens (#287)
1 parent d0b2cfe commit 7ff2b43

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.github/workflows/addToProject.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ name: Auto Assign to Project(s)
44
on:
55
issues:
66
types: [opened, edited, milestoned]
7-
env:
8-
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
97

108
permissions:
119
contents: read
@@ -15,10 +13,24 @@ jobs:
1513
runs-on: ubuntu-latest
1614
name: Assign milestoned to Project
1715
steps:
16+
- name: Get token
17+
id: get_token
18+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
19+
with:
20+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
21+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
22+
permissions: >-
23+
{
24+
"organization_projects": "write",
25+
"issues": "read"
26+
}
27+
1828
- name: Assign issues with milestones to project
1929
uses: elastic/assign-one-project-github-action@1.2.2
2030
if: github.event.issue && github.event.issue.milestone
2131
with:
2232
project: 'https://github.com/orgs/elastic/projects/454'
2333
project_id: '5882982'
2434
column_name: 'Planned'
35+
env:
36+
MY_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
@@ -22,6 +20,18 @@ jobs:
2220
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2321
configuration-path: .github/labeler-config.yml
2422
enable-versioned-regex: 0
23+
- name: Get token
24+
id: get_token
25+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
26+
with:
27+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
28+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
29+
permissions: >-
30+
{
31+
"members": "read",
32+
"organization_projects": "write",
33+
"issues": "read"
34+
}
2535
- name: Check team membership for user
2636
uses: elastic/get-user-teams-membership@1.1.0
2737
id: checkUserMember
@@ -32,7 +42,7 @@ jobs:
3242
apmmachine
3343
dependabot
3444
obltmachine
35-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
45+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
3646
- name: Show team membership
3747
run: |
3848
echo "::debug::isTeamMember: ${{ steps.checkUserMember.outputs.isTeamMember }}"
@@ -51,3 +61,5 @@ jobs:
5161
project: 'https://github.com/orgs/elastic/projects/454'
5262
project_id: '5882982'
5363
column_name: 'In Progress'
64+
env:
65+
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

0 commit comments

Comments
 (0)