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