FROBENIUS: reduction of char poly from B to B/Q #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Claim Issue | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
claim_issue: | |
if: github.event.issue.pull_request == null && github.event.comment.body == 'claim' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if issue is already assigned | |
id: check_assignee | |
run: | | |
ASSIGNEES_COUNT=$(echo "${{ toJson(github.event.issue.assignees) }}" | jq length) | |
if [ "$ASSIGNEES_COUNT" -gt 0 ]; then | |
echo "Issue is already assigned." | |
exit 0 | |
fi | |
- name: Assign the issue to the commenter | |
run: | | |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-d '{"assignees":["${{ github.event.comment.user.login }}"]}' \ | |
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} | |
- name: Log the assignment result | |
run: echo "Issue successfully assigned to ${{ github.event.comment.user.login }}." | |
- name: Retrieve the project ITEM_ID | |
id: get_item_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ repository(owner: \\"${{ github.repository_owner }}\\", name: \\"${{ github.event.repository.name }}\\") { issue(number: ${{ github.event.issue.number }}) { projectItems(first: 10) { nodes { id } } } } }" | |
} | |
EOF | |
) | |
echo "Sending query: $QUERY" | |
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" https://api.github.com/graphql) | |
echo "GraphQL Response: $RESPONSE" | |
ITEM_ID=$(echo "$RESPONSE" | jq -r '.data.repository.issue.projectItems.nodes[0].id') | |
if [ -z "$ITEM_ID" ]; then | |
echo "Error: Could not retrieve ITEM_ID" | |
exit 1 | |
else | |
echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV | |
fi | |
- name: Retrieve the project FIELD_ID for "Status" | |
id: get_field_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name id } } } } } }" | |
} | |
EOF | |
) | |
echo "Sending query: $QUERY" | |
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" https://api.github.com/graphql) | |
echo "GraphQL Response: $RESPONSE" | |
FIELD_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status").id') | |
if [ -z "$FIELD_ID" ]; then | |
echo "Error: Could not retrieve FIELD_ID for Status" | |
exit 1 | |
else | |
echo "FIELD_ID=$FIELD_ID" >> $GITHUB_ENV | |
fi | |
- name: Retrieve the "Claimed" option ID | |
id: find_claimed_tasks_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ node(id: \\"PVT_kwHOAeZDs84ApSkY\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name options { id name } } } } } } }" | |
} | |
EOF | |
) | |
echo "Sending query: $QUERY" | |
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" https://api.github.com/graphql) | |
echo "GraphQL Response: $RESPONSE" | |
CLAIMED_TASKS_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status") | .options[] | select(.name == "Claimed").id') | |
if [ -z "$CLAIMED_TASKS_ID" ]; then | |
echo "Error: Could not retrieve 'Claimed' ID" | |
exit 1 | |
else | |
echo "CLAIMED_TASKS_ID=$CLAIMED_TASKS_ID" >> $GITHUB_ENV | |
fi | |
- name: Move task to "Claimed" column | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "mutation { updateProjectV2ItemFieldValue(input: { projectId: \\"PVT_kwHOAeZDs84ApSkY\\", itemId: \\"$ITEM_ID\\", fieldId: \\"$FIELD_ID\\", value: { singleSelectOptionId: \\"$CLAIMED_TASKS_ID\\" } }) { projectV2Item { id } } }" | |
} | |
EOF | |
) | |
curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" \ | |
https://api.github.com/graphql | |
- name: Log the project card movement result | |
run: echo "Task successfully moved to 'Claimed' column." |