FINITE: Refute 3475 -> 3659 #974
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: Disclaim Issue | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
disclaim_issue: | |
if: github.event.issue.pull_request == null && contains(github.event.comment.body, 'disclaim') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if comment contains only 'disclaim' (ignoring white spaces, newlines, and case) | |
id: check_disclaim | |
env: | |
COMMENT: ${{ github.event.comment.body }} | |
run: | | |
TRIMMED_COMMENT=$(echo "$COMMENT" | tr -d '\n' | xargs | tr '[:upper:]' '[:lower:]') | |
if [ "$TRIMMED_COMMENT" != "disclaim" ]; then | |
echo "Comment does not contain only 'disclaim' modulo white spaces, newlines and case." | |
exit 1 | |
fi | |
echo "Disclaim comment detected." | |
- name: Retrieve project ID | |
id: get_project_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ repository(owner: \\"${{ github.repository_owner }}\\", name: \\"${{ github.event.repository.name }}\\") { projectsV2(first: 10) { nodes { id title } } } }" | |
} | |
EOF | |
) | |
RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" https://github.com/graphql) | |
PROJECT_ID=$(echo "$RESPONSE" | jq -r '.data.repository.projectsV2.nodes[] | select(.title == "Equational Theories Project").id') | |
if [ -z "$PROJECT_ID" ]; then | |
echo "Error: Could not retrieve project ID" | |
exit 1 | |
else | |
echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV | |
fi | |
- name: Get issue details | |
id: issue | |
run: | | |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }} > issue.json | |
cat issue.json | |
continue-on-error: true | |
- name: Check if the commenter is assigned to the issue | |
id: check_assignee | |
run: | | |
COMMENTER="${{ github.event.comment.user.login }}" | |
ASSIGNED=$(jq --arg user "$COMMENTER" '.assignees[]?.login | select(. == $user)' issue.json) | |
if [ -z "$ASSIGNED" ]; then | |
echo "not_assigned=true" >> $GITHUB_ENV | |
else | |
echo "not_assigned=false" >> $GITHUB_ENV | |
fi | |
- name: Remove the user from the assignees | |
if: env.not_assigned == 'false' | |
run: | | |
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-d '{"assignees":["${{ github.event.comment.user.login }}"]}' \ | |
https://github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees | |
- name: Log the unassignment result | |
if: env.not_assigned == 'false' | |
run: echo "User ${{ github.event.comment.user.login }} has been unassigned from the issue." | |
- 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://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: \\"${{ env.PROJECT_ID }}\\") { ... on ProjectV2 { fields(first: 10) { nodes { ... on ProjectV2SingleSelectField { name id } ... on ProjectV2IterationField { 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://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 "Unclaimed Outstanding Tasks" option ID | |
id: find_unclaimed_tasks_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ node(id: \\"${{ env.PROJECT_ID }}\\") { ... 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://github.com/graphql) | |
echo "GraphQL Response: $RESPONSE" | |
UNCLAIMED_TASKS_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status") | .options[] | select(.name == "Unclaimed Outstanding Tasks").id') | |
if [ -z "$UNCLAIMED_TASKS_ID" ]; then | |
echo "Error: Could not retrieve 'Unclaimed Outstanding Tasks' ID" | |
exit 1 | |
else | |
echo "UNCLAIMED_TASKS_ID=$UNCLAIMED_TASKS_ID" >> $GITHUB_ENV | |
fi | |
- name: Move task to "Unclaimed Outstanding Tasks" column | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "mutation { updateProjectV2ItemFieldValue(input: { projectId: \\"${{ env.PROJECT_ID }}\\", itemId: \\"$ITEM_ID\\", fieldId: \\"$FIELD_ID\\", value: { singleSelectOptionId: \\"$UNCLAIMED_TASKS_ID\\" } }) { projectV2Item { id } } }" | |
} | |
EOF | |
) | |
curl -X POST -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "$QUERY" \ | |
https://github.com/graphql | |
- name: Log the project card movement result | |
run: echo "Task successfully moved to 'Unclaimed Outstanding Tasks' column." |