Skip to content

Commit ce2f9f7

Browse files
authored
fix labeler + automaticaly add to GH project (#4037)
* add new way to check permissions * align with android repo * add workflow dispatch * disable add label * restove project assignment * add to project board * try to set agent * remove condition on PR * provide gh token * first working draft * use test PR URL * remove test PR url and make it ready for use * restore java-agent label * use hardcoded issue ID * use issue-labeler * remove warning for unused config option * restore it * try to reuse common code * try to fix token * reuse set status * fix test url * try to set agent field * try to set iteration * cleanup, still not ready for prime-time * switch to project numeric ID * use new parameters format * try to set previous * try with next * use iteration name * restore conditions in labeler workflow * use elastic version * simplify and avoid issue-labeler * cleanup * another cleanup * add missing NUMBER and GH_TOKEN * simplify use the PR url
1 parent d635dad commit ce2f9f7

File tree

1 file changed

+64
-41
lines changed

1 file changed

+64
-41
lines changed

.github/workflows/labeler.yml

+64-41
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ jobs:
1414
triage:
1515
runs-on: ubuntu-latest
1616
steps:
17+
1718
- name: Add agent-java label
18-
uses: actions/github-script@v7
19-
with:
20-
script: |
21-
github.rest.issues.addLabels({
22-
issue_number: context.issue.number,
23-
owner: context.repo.owner,
24-
repo: context.repo.repo,
25-
labels: ["agent-java"]
26-
})
19+
run: gh issue edit "${NUMBER}" --add-label "agent-java" --repo "${{ github.repository }}"
20+
env:
21+
NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2723

2824
- name: Get token
2925
id: get_token
@@ -38,41 +34,68 @@ jobs:
3834
"issues": "read"
3935
}
4036
41-
- id: is_elastic_member
42-
uses: elastic/oblt-actions/github/is-member-of@v1
37+
- name: Check team membership for user
38+
uses: elastic/[email protected]
39+
id: checkUserMember
4340
with:
44-
github-org: "elastic"
45-
github-user: ${{ github.actor }}
46-
github-token: ${{ steps.get_token.outputs.token }}
41+
username: ${{ github.actor }}
42+
team: 'apm'
43+
usernamesToExclude: |
44+
dependabot
45+
dependabot[bot]
46+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
47+
48+
- name: Show team membership
49+
run: |
50+
echo "::debug::isTeamMember: ${{ steps.checkUserMember.outputs.isTeamMember }}"
51+
echo "::debug::isExcluded: ${{ steps.checkUserMember.outputs.isExcluded }}"
4752
4853
- name: Add community and triage labels
49-
if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-renovate-prod[bot]' && github.actor != 'elastic-observability-automation[bot]'
50-
uses: actions/github-script@v7
54+
if: steps.checkUserMember.outputs.isTeamMember != 'true' && steps.checkUserMember.outputs.isExcluded != 'true'
55+
run: gh issue edit "${NUMBER}" --add-label "community,triage" --repo "${{ github.repository }}"
56+
env:
57+
NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Assign new internal pull requests to project
61+
id: add-to-project
62+
if: (steps.checkUserMember.outputs.isTeamMember == 'true' || steps.checkUserMember.outputs.isExcluded == 'true') && github.event_name == 'pull_request'
63+
uses: elastic/oblt-actions/github/project-add@v1
64+
with:
65+
github-token: ${{ steps.get_token.outputs.token }}
66+
project-id: 1829
67+
item-url: "${{ github.event.pull_request.url }}"
68+
69+
- name: set status in project
70+
id: set-project-status-field
71+
if: (steps.checkUserMember.outputs.isTeamMember == 'true' || steps.checkUserMember.outputs.isExcluded == 'true') && github.event_name == 'pull_request'
72+
uses: elastic/oblt-actions/github/project-field-set@v1
5173
with:
52-
script: |
53-
github.rest.issues.addLabels({
54-
issue_number: context.issue.number,
55-
owner: context.repo.owner,
56-
repo: context.repo.repo,
57-
labels: ["community", "triage"]
58-
})
59-
- name: Add comment for community PR
60-
if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-renovate-prod[bot]' && github.actor != 'elastic-observability-automation[bot]'
61-
uses: wow-actions/auto-comment@2fc064c21cfb2505de3c5c10e1473b8eb7beca1a # v1.1.2
74+
github-token: ${{ steps.get_token.outputs.token }}
75+
project-id: 1829
76+
item-id: ${{ steps.add-to-project.outputs.item-id }}
77+
field-name: 'Status'
78+
field-value: 'In Progress'
79+
80+
- name: set agent in project
81+
id: set-project-agent-field
82+
if: (steps.checkUserMember.outputs.isTeamMember == 'true' || steps.checkUserMember.outputs.isExcluded == 'true') && github.event_name == 'pull_request'
83+
uses: elastic/oblt-actions/github/project-field-set@v1
6284
with:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
pullRequestOpened: |
65-
👋 @{{ author }} Thanks a lot for your contribution!
66-
67-
It may take some time before we review a PR, so even if you don’t see activity for some time, it **does not** mean that we have forgotten about it.
68-
69-
Every once in a while we go through a process of prioritization, after which we are focussing on the tasks that were planned for the upcoming [milestone](https://github.com/elastic/apm-agent-java/milestones). The prioritization status is typically reflected through the PR labels. It could be pending triage, a candidate for a future milestone, or have a target milestone set to it.
70-
- name: Assign new internal pull requests to project
71-
uses: elastic/[email protected]
72-
if: contains(steps.is_elastic_member.outputs.result, 'true') && github.event.pull_request
73-
env:
74-
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
85+
github-token: ${{ steps.get_token.outputs.token }}
86+
project-id: 1829
87+
item-id: ${{ steps.add-to-project.outputs.item-id }}
88+
field-name: 'Agent'
89+
field-value: 'java'
90+
91+
- name: set iteration in project
92+
id: set-project-iteration-field
93+
if: (steps.checkUserMember.outputs.isTeamMember == 'true' || steps.checkUserMember.outputs.isExcluded == 'true') && github.event_name == 'pull_request'
94+
uses: elastic/oblt-actions/github/project-field-set@v1
7595
with:
76-
project: 'https://github.com/orgs/elastic/projects/454'
77-
project_id: '5882982'
78-
column_name: 'In Progress'
96+
github-token: ${{ steps.get_token.outputs.token }}
97+
project-id: 1829
98+
item-id: ${{ steps.add-to-project.outputs.item-id }}
99+
field-name: 'Iteration'
100+
field-value: '@current'
101+
field-type: 'iteration'

0 commit comments

Comments
 (0)