Skip to content
name: Bot Review
on:
pull_request:
types:
- opened
- edited
jobs:
bot_review:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set PR as Draft
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)

Check failure on line 21 in .github/workflows/pr_review_bot.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/pr_review_bot.yaml

Invalid workflow file

You have an error in your yaml syntax on line 21
REPO_OWNER=$(jq --raw-output .repository.owner.login $GITHUB_EVENT_PATH)
REPO_NAME=$(jq --raw-output .repository.name $GITHUB_EVENT_PATH)
# Query GitHub API v4 to get the base64-encoded ID of the pull request
base64_encoded_id=$(curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
--data-raw "{
\"query\": \"query {
repository(owner: \\\"$REPO_OWNER\\\", name: \\\"$REPO_NAME\\\"){
pullRequest(number: $PR_NUMBER) {
id
}
}
}\"
}" \
"https://api.github.com/graphql" | jq -r .data.repository.pullRequest.id)
# Output the base64-encoded ID for reference
echo "Base64 Encoded ID: $base64_encoded_id"
# If the base64-encoded ID is available, proceed with updating the pull request
# Use the obtained ID to convert the pull request to draft status
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
--data-raw "{
\"query\": \"mutation {
convertPullRequestToDraft(input: {pullRequestId: \\\"$base64_encoded_id\\\"}) {}
}\"
}" \
"https://api.github.com/graphql"
- name: Set Up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Dependencies
run: pip install PyGithub
- name: Run Bot Review
run: python scripts/review_bot.py "${{ github.event_path }}"
- name: Set PR as Ready
if: success()
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)
REPO_OWNER=$(jq --raw-output .repository.owner.login $GITHUB_EVENT_PATH)
REPO_NAME=$(jq --raw-output .repository.name $GITHUB_EVENT_PATH)
graphql_query='mutation ConvertToReady { markPullRequestReadyForReview(input: {pullRequestId: "'$PR_NUMBER'"}) { clientMutationId } }'
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
--data-raw '{"query": "'"$graphql_query"'"}' \
"https://api.github.com/graphql"