Skip to content

Commit ab51dea

Browse files
maiieulgioboa
andauthored
chore: autmatically assign core team members to their PRs and "Qwik Development" project with proper status (#8066)
* chore: autmatically assign core team members to their PRs * chore: add core-team PR to Qwik Development project * chore: auto assign core-team PR to proper project status (progress or review) * chore: remove comment * fix: yml error --------- Co-authored-by: Giorgio Boa <35845425+gioboa@users.noreply.github.com>
1 parent 3d757bf commit ab51dea

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Auto-assign PRs to core team authors
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, ready_for_review, converted_to_draft]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: read
10+
11+
jobs:
12+
auto_assign:
13+
name: Assign PR author when core team member
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check team membership via REST
17+
id: team
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
ORG: QwikDev
21+
TEAM_SLUG: qwik-team
22+
AUTHOR: ${{ github.event.pull_request.user.login }}
23+
run: |
24+
RESPONSE=$(curl -s \
25+
-H "Authorization: token ${GH_TOKEN}" \
26+
-H "Accept: application/vnd.github+json" \
27+
"https://api.github.com/orgs/${ORG}/teams/${TEAM_SLUG}/memberships/${AUTHOR}")
28+
29+
STATE=$(echo "$RESPONSE" | jq -r '.state // empty')
30+
if [ "$STATE" = "active" ]; then
31+
echo "isCore=true" >> $GITHUB_OUTPUT
32+
else
33+
echo "isCore=false" >> $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Assign PR to author
37+
if: steps.team.outputs.isCore == 'true'
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
PR_NUMBER=${{ github.event.pull_request.number }}
42+
AUTHOR=${{ github.event.pull_request.user.login }}
43+
curl -s -H "Authorization: token ${GH_TOKEN}" \
44+
-H "Accept: application/vnd.github+json" \
45+
-X POST \
46+
-d "{\"assignees\":[\"${AUTHOR}\"]}" \
47+
https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/assignees
48+
49+
- name: Add PR to Qwik Development project
50+
if: steps.team.outputs.isCore == 'true'
51+
uses: actions/add-to-project@v0.6.1
52+
with:
53+
project-url: https://github.com/orgs/QwikDev/projects/1
54+
github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
55+
56+
- name: Ensure project + set Status to "In progress" (draft)
57+
if: steps.team.outputs.isCore == 'true' && github.event.pull_request.draft == true
58+
uses: actions/add-to-project@v0.6.1
59+
with:
60+
project-url: https://github.com/orgs/QwikDev/projects/1
61+
github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
62+
fields: |
63+
Status: In progress
64+
65+
- name: Ensure project + set Status to "Waiting For Review" (ready)
66+
if: steps.team.outputs.isCore == 'true' && github.event.pull_request.draft == false
67+
uses: actions/add-to-project@v0.6.1
68+
with:
69+
project-url: https://github.com/orgs/QwikDev/projects/1
70+
github-token: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
71+
fields: |
72+
Status: Waiting For Review

0 commit comments

Comments
 (0)