Skip to content

Commit 6dcd5e8

Browse files
authored
github-actions: use GH app to manage the projects (#3829)
1 parent d7f690c commit 6dcd5e8

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

.github/workflows/addToProject.yml

Lines changed: 16 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,21 @@ 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+
"organization_projects": "write",
24+
"issues": "read"
25+
}
26+
1427
- name: Get project data
1528
env:
16-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
29+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
1730
TEAM: Java
1831
ORGANIZATION: elastic
1932
PROJECT_NUMBER: 595
@@ -49,7 +62,7 @@ jobs:
4962
5063
- name: Add issue to project
5164
env:
52-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
65+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
5366
ISSUE_ID: ${{ github.event.issue.node_id }}
5467
run: |
5568
item_id="$( gh api graphql -f query='
@@ -65,7 +78,7 @@ jobs:
6578
6679
- name: Set fields
6780
env:
68-
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
81+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6982
run: |
7083
gh api graphql -f query='
7184
mutation (

.github/workflows/labeler.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,27 @@ 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+
"organization_projects": "write",
38+
"issues": "read"
39+
}
40+
2741
- id: is_elastic_member
2842
uses: elastic/oblt-actions/github/is-member-of@v1
2943
with:
3044
github-org: "elastic"
3145
github-user: ${{ github.actor }}
32-
github-token: ${{ secrets.APM_TECH_USER_TOKEN }}
46+
github-token: ${{ steps.get_token.outputs.token }}
47+
3348
- name: Add community and triage lables
3449
if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-renovate-prod[bot]'
3550
uses: actions/github-script@v7
@@ -56,7 +71,7 @@ jobs:
5671
uses: elastic/[email protected]
5772
if: contains(steps.is_elastic_member.outputs.result, 'true') && github.event.pull_request
5873
env:
59-
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
74+
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
6075
with:
6176
project: 'https://github.com/orgs/elastic/projects/454'
6277
project_id: '5882982'

0 commit comments

Comments
 (0)