Skip to content

Commit e040fde

Browse files
authored
Build dashboard-based infrastructure (#153)
* rename update-dependencies workflow * Create CONTRIBUTING.md * Update CONTRIBUTING.md * Create 01-claim-issue.yml * Create 02-disclaim-issue.yml * Create 03-propose-pr.yml * Create 04-withdraw-pr.yml * Create 05-awaiting-review.yml * Add project id
1 parent 05a0e5e commit e040fde

7 files changed

+738
-0
lines changed

.github/workflows/01-claim-issue.yml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Claim Issue
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
claim_issue:
9+
if: github.event.issue.pull_request == null && github.event.comment.body == 'claim'
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check if issue is already assigned
14+
id: check_assignee
15+
run: |
16+
ASSIGNEES_COUNT=$(echo "${{ toJson(github.event.issue.assignees) }}" | jq length)
17+
if [ "$ASSIGNEES_COUNT" -gt 0 ]; then
18+
echo "Issue is already assigned."
19+
exit 0
20+
fi
21+
22+
- name: Assign the issue to the commenter
23+
run: |
24+
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
25+
-d '{"assignees":["${{ github.event.comment.user.login }}"]}' \
26+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}
27+
28+
- name: Log the assignment result
29+
run: echo "Issue successfully assigned to ${{ github.event.comment.user.login }}."
30+
31+
- name: Retrieve the project ITEM_ID
32+
id: get_item_id
33+
run: |
34+
QUERY=$(cat <<EOF
35+
{
36+
"query": "{ repository(owner: \\"${{ github.repository_owner }}\\", name: \\"${{ github.event.repository.name }}\\") { issue(number: ${{ github.event.issue.number }}) { projectItems(first: 10) { nodes { id } } } } }"
37+
}
38+
EOF
39+
)
40+
echo "Sending query: $QUERY"
41+
42+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
43+
-H "Content-Type: application/json" \
44+
--data "$QUERY" https://api.github.com/graphql)
45+
46+
echo "GraphQL Response: $RESPONSE"
47+
ITEM_ID=$(echo "$RESPONSE" | jq -r '.data.repository.issue.projectItems.nodes[0].id')
48+
49+
if [ -z "$ITEM_ID" ]; then
50+
echo "Error: Could not retrieve ITEM_ID"
51+
exit 1
52+
else
53+
echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV
54+
fi
55+
56+
- name: Retrieve the project FIELD_ID for "Status"
57+
id: get_field_id
58+
run: |
59+
QUERY=$(cat <<EOF
60+
{
61+
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name id } } } } } }"
62+
}
63+
EOF
64+
)
65+
echo "Sending query: $QUERY"
66+
67+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
68+
-H "Content-Type: application/json" \
69+
--data "$QUERY" https://api.github.com/graphql)
70+
71+
echo "GraphQL Response: $RESPONSE"
72+
FIELD_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status").id')
73+
74+
if [ -z "$FIELD_ID" ]; then
75+
echo "Error: Could not retrieve FIELD_ID for Status"
76+
exit 1
77+
else
78+
echo "FIELD_ID=$FIELD_ID" >> $GITHUB_ENV
79+
fi
80+
81+
- name: Retrieve the "Claimed" option ID
82+
id: find_claimed_tasks_id
83+
run: |
84+
QUERY=$(cat <<EOF
85+
{
86+
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name options { id name } } } } } } }"
87+
}
88+
EOF
89+
)
90+
echo "Sending query: $QUERY"
91+
92+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
93+
-H "Content-Type: application/json" \
94+
--data "$QUERY" https://api.github.com/graphql)
95+
96+
echo "GraphQL Response: $RESPONSE"
97+
CLAIMED_TASKS_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status") | .options[] | select(.name == "Claimed").id')
98+
99+
if [ -z "$CLAIMED_TASKS_ID" ]; then
100+
echo "Error: Could not retrieve 'Claimed' ID"
101+
exit 1
102+
else
103+
echo "CLAIMED_TASKS_ID=$CLAIMED_TASKS_ID" >> $GITHUB_ENV
104+
fi
105+
106+
- name: Move task to "Claimed" column
107+
run: |
108+
QUERY=$(cat <<EOF
109+
{
110+
"query": "mutation { updateProjectV2ItemFieldValue(input: { projectId: \\"PVT_kwHOAeZDs84ApSkY\\", itemId: \\"$ITEM_ID\\", fieldId: \\"$FIELD_ID\\", value: { singleSelectOptionId: \\"$CLAIMED_TASKS_ID\\" } }) { projectV2Item { id } } }"
111+
}
112+
EOF
113+
)
114+
curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
115+
-H "Content-Type: application/json" \
116+
--data "$QUERY" \
117+
https://api.github.com/graphql
118+
119+
- name: Log the project card movement result
120+
run: echo "Task successfully moved to 'Claimed' column."
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Disclaim Issue
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
disclaim_issue:
9+
if: github.event.issue.pull_request == null && github.event.comment.body == 'disclaim'
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Get issue details
14+
id: issue
15+
run: |
16+
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
17+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} > issue.json
18+
cat issue.json
19+
continue-on-error: true
20+
21+
- name: Check if the commenter is assigned to the issue
22+
id: check_assignee
23+
run: |
24+
COMMENTER="${{ github.event.comment.user.login }}"
25+
ASSIGNED=$(jq --arg user "$COMMENTER" '.assignees[]?.login | select(. == $user)' issue.json)
26+
if [ -z "$ASSIGNED" ]; then
27+
echo "not_assigned=true" >> $GITHUB_ENV
28+
else
29+
echo "not_assigned=false" >> $GITHUB_ENV
30+
fi
31+
32+
- name: Remove the user from the assignees
33+
if: env.not_assigned == 'false'
34+
run: |
35+
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
36+
-d '{"assignees":["${{ github.event.comment.user.login }}"]}' \
37+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
38+
39+
- name: Log the unassignment result
40+
if: env.not_assigned == 'false'
41+
run: echo "User ${{ github.event.comment.user.login }} has been unassigned from the issue."
42+
43+
- name: Retrieve the project ITEM_ID
44+
id: get_item_id
45+
run: |
46+
QUERY=$(cat <<EOF
47+
{
48+
"query": "{ repository(owner: \\"${{ github.repository_owner }}\\", name: \\"${{ github.event.repository.name }}\\") { issue(number: ${{ github.event.issue.number }}) { projectItems(first: 10) { nodes { id } } } } }"
49+
}
50+
EOF
51+
)
52+
echo "Sending query: $QUERY"
53+
54+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
55+
-H "Content-Type: application/json" \
56+
--data "$QUERY" https://api.github.com/graphql)
57+
58+
echo "GraphQL Response: $RESPONSE"
59+
ITEM_ID=$(echo "$RESPONSE" | jq -r '.data.repository.issue.projectItems.nodes[0].id')
60+
61+
if [ -z "$ITEM_ID" ]; then
62+
echo "Error: Could not retrieve ITEM_ID"
63+
exit 1
64+
else
65+
echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV
66+
fi
67+
68+
- name: Retrieve the project FIELD_ID for "Status"
69+
id: get_field_id
70+
run: |
71+
QUERY=$(cat <<EOF
72+
{
73+
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name id } ... on ProjectV2IterationField { name id } } } } } }"
74+
}
75+
EOF
76+
)
77+
echo "Sending query: $QUERY"
78+
79+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
80+
-H "Content-Type: application/json" \
81+
--data "$QUERY" https://api.github.com/graphql)
82+
83+
echo "GraphQL Response: $RESPONSE"
84+
FIELD_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status").id')
85+
86+
if [ -z "$FIELD_ID" ]; then
87+
echo "Error: Could not retrieve FIELD_ID for Status"
88+
exit 1
89+
else
90+
echo "FIELD_ID=$FIELD_ID" >> $GITHUB_ENV
91+
fi
92+
93+
- name: Retrieve the "Unclaimed" option ID
94+
id: find_unclaimed_tasks_id
95+
run: |
96+
QUERY=$(cat <<EOF
97+
{
98+
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name options { id name } } } } } } }"
99+
}
100+
EOF
101+
)
102+
echo "Sending query: $QUERY"
103+
104+
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
105+
-H "Content-Type: application/json" \
106+
--data "$QUERY" https://api.github.com/graphql)
107+
108+
echo "GraphQL Response: $RESPONSE"
109+
UNCLAIMED_TASKS_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status") | .options[] | select(.name == "Unclaimed").id')
110+
111+
if [ -z "$UNCLAIMED_TASKS_ID" ]; then
112+
echo "Error: Could not retrieve 'Unclaimed' ID"
113+
exit 1
114+
else
115+
echo "UNCLAIMED_TASKS_ID=$UNCLAIMED_TASKS_ID" >> $GITHUB_ENV
116+
fi
117+
118+
- name: Move task to "Unclaimed" column
119+
run: |
120+
QUERY=$(cat <<EOF
121+
{
122+
"query": "mutation { updateProjectV2ItemFieldValue(input: { projectId: \\"PVT_kwHOAeZDs84ApSkY\\", itemId: \\"$ITEM_ID\\", fieldId: \\"$FIELD_ID\\", value: { singleSelectOptionId: \\"$UNCLAIMED_TASKS_ID\\" } }) { projectV2Item { id } } }"
123+
}
124+
EOF
125+
)
126+
curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \
127+
-H "Content-Type: application/json" \
128+
--data "$QUERY" \
129+
https://api.github.com/graphql
130+
131+
- name: Log the project card movement result
132+
run: echo "Task successfully moved to 'Unclaimed' column."

0 commit comments

Comments
 (0)