Skip to content

Commit

Permalink
github-actions: use ephemeral tokens (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Oct 8, 2024
1 parent d0b2cfe commit 7ff2b43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/addToProject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ name: Auto Assign to Project(s)
on:
issues:
types: [opened, edited, milestoned]
env:
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}

permissions:
contents: read
Expand All @@ -15,10 +13,24 @@ jobs:
runs-on: ubuntu-latest
name: Assign milestoned to Project
steps:
- 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: >-
{
"organization_projects": "write",
"issues": "read"
}
- name: Assign issues with milestones to project
uses: elastic/[email protected]
if: github.event.issue && github.event.issue.milestone
with:
project: 'https://github.com/orgs/elastic/projects/454'
project_id: '5882982'
column_name: 'Planned'
env:
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
18 changes: 15 additions & 3 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
types: [opened]
pull_request_target:
types: [opened]
env:
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}

permissions:
contents: read
Expand All @@ -22,6 +20,18 @@ jobs:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler-config.yml
enable-versioned-regex: 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: >-
{
"members": "read",
"organization_projects": "write",
"issues": "read"
}
- name: Check team membership for user
uses: elastic/[email protected]
id: checkUserMember
Expand All @@ -32,7 +42,7 @@ jobs:
apmmachine
dependabot
obltmachine
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
- name: Show team membership
run: |
echo "::debug::isTeamMember: ${{ steps.checkUserMember.outputs.isTeamMember }}"
Expand All @@ -51,3 +61,5 @@ jobs:
project: 'https://github.com/orgs/elastic/projects/454'
project_id: '5882982'
column_name: 'In Progress'
env:
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}

0 comments on commit 7ff2b43

Please sign in to comment.