FINITE: Refute 3475 -> 3659 #975
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: Awaiting Review | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
awaiting_review: | |
if: github.event.issue.pull_request != null && contains(github.event.comment.body, 'awaiting-review') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Add "awaiting-review" label to the PR | |
run: | | |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-d '{"labels":["awaiting-review"]}' \ | |
https://github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels | |
- 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 PR details | |
id: get_pr | |
run: | | |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} > pr.json | |
cat pr.json | |
- name: Extract related issue number | |
id: extract_issue | |
run: | | |
ISSUE_NUMBER=$(jq -r '.body | capture("Closes #(?<num>[0-9]+)") | .num' pr.json) | |
echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_ENV | |
- name: Fail if no related issue is found | |
if: ${{ env.issue_number == '' }} | |
run: | | |
echo "No related issue found in PR body. Exiting..." | |
exit 1 | |
- name: Retrieve the project ITEM_ID for the related issue | |
id: get_item_id | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "{ repository(owner: \\"${{ github.repository_owner }}\\", name: \\"${{ github.event.repository.name }}\\") { issue(number: ${{ env.issue_number }}) { projectItems(first: 10) { nodes { id } } } } }" | |
} | |
EOF | |
) | |
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 } } } } } }" | |
} | |
EOF | |
) | |
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 "PRs in Review" option ID | |
id: find_in_review_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 | |
) | |
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" | |
PR_IN_REVIEW_ID=$(echo "$RESPONSE" | jq -r '.data.node.fields.nodes[] | select(.name == "Status") | .options[] | select(.name == "PRs in Review").id') | |
if [ -z "$PR_IN_REVIEW_ID" ]; then | |
echo "Error: Could not retrieve 'PRs in Review' ID" | |
exit 1 | |
else | |
echo "PR_IN_REVIEW_ID=$PR_IN_REVIEW_ID" >> $GITHUB_ENV | |
fi | |
- name: Move task to "PRs in Review" column | |
run: | | |
QUERY=$(cat <<EOF | |
{ | |
"query": "mutation { updateProjectV2ItemFieldValue(input: { projectId: \\"${{ env.PROJECT_ID }}\\", itemId: \\"$ITEM_ID\\", fieldId: \\"$FIELD_ID\\", value: { singleSelectOptionId: \\"$PR_IN_REVIEW_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 'PRs in Review' column." |