Skip to content

Commit a8442b7

Browse files
committed
github-actions: use GH app to manage the projects
1 parent 1fda0dd commit a8442b7

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/addToProject.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
issues:
44
types:
55
- opened, milestoned
6+
67
permissions:
78
contents: read
89

@@ -11,9 +12,20 @@ jobs:
1112
if: github.event.issue && github.event.issue.milestone
1213
runs-on: ubuntu-latest
1314
steps:
15+
- name: Get token
16+
id: get_token
17+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
18+
with:
19+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
20+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
21+
permissions: >-
22+
{
23+
"repository_projects": "write"
24+
}
25+
1426
- name: Get project data
1527
env:
16-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
28+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
1729
TEAM: Java
1830
ORGANIZATION: elastic
1931
PROJECT_NUMBER: 595
@@ -49,7 +61,7 @@ jobs:
4961
5062
- name: Add issue to project
5163
env:
52-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
64+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
5365
ISSUE_ID: ${{ github.event.issue.node_id }}
5466
run: |
5567
item_id="$( gh api graphql -f query='
@@ -65,7 +77,7 @@ jobs:
6577
6678
- name: Set fields
6779
env:
68-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
80+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6981
run: |
7082
gh api graphql -f query='
7183
mutation (

.github/workflows/labeler.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,26 @@ jobs:
2424
repo: context.repo.repo,
2525
labels: ["agent-java"]
2626
})
27+
28+
- name: Get token
29+
id: get_token
30+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
31+
with:
32+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
33+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
34+
permissions: >-
35+
{
36+
"members": "read",
37+
"repository_projects": "write"
38+
}
39+
2740
- id: is_elastic_member
2841
uses: elastic/oblt-actions/github/is-member-of@v1
2942
with:
3043
github-org: "elastic"
3144
github-user: ${{ github.actor }}
32-
github-token: ${{ secrets.APM_TECH_USER_TOKEN }}
45+
github-token: ${{ steps.get_token.outputs.token }}
46+
3347
- name: Add community and triage lables
3448
if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-renovate-prod[bot]'
3549
uses: actions/github-script@v7
@@ -56,7 +70,7 @@ jobs:
5670
uses: elastic/[email protected]
5771
if: contains(steps.is_elastic_member.outputs.result, 'true') && github.event.pull_request
5872
env:
59-
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
73+
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6074
with:
6175
project: 'https://github.com/orgs/elastic/projects/454'
6276
project_id: '5882982'

0 commit comments

Comments
 (0)