diff --git a/graphql-disable-auto-merge.sh b/graphql-disable-auto-merge.sh new file mode 100755 index 00000000..a4b15c82 --- /dev/null +++ b/graphql-disable-auto-merge.sh @@ -0,0 +1,35 @@ +. ./.gh-api-examples.conf + +# https://docs.github.com/en/graphql/reference/mutations#disablepullrequestautomerge + + +if [ -z "$1" ] + then + pull_request_node_id=$(./list-pull-request.sh | jq -r '.node_id') + else + pull_request_node_id=$1 +fi + + +graphql_query=tmp/graphql-enable-pull-request-auto-merge.txt + +cat <$graphql_query +mutation automerge { + disablePullRequestAutoMerge(input: {pullRequestId: "$pull_request_node_id" }) { + clientMutationId + } +} +EOF + +json_file=tmp/graphql-payload.json + +jq -n \ + --arg graphql_query "$(cat $graphql_query)" \ + '{query: $graphql_query}' > ${json_file} + + +curl ${curl_custom_flags} \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + ${GITHUB_APIV4_BASE_URL} -d @${json_file} | jq + diff --git a/graphql-enable-auto-merge.sh b/graphql-enable-auto-merge.sh new file mode 100755 index 00000000..5a01e401 --- /dev/null +++ b/graphql-enable-auto-merge.sh @@ -0,0 +1,35 @@ +. ./.gh-api-examples.conf + +# https://docs.github.com/en/graphql/reference/mutations#enablepullrequestautomerge + + +if [ -z "$1" ] + then + pull_request_node_id=$(./list-pull-request.sh | jq -r '.node_id') + else + pull_request_node_id=$1 +fi + + +graphql_query=tmp/graphql-enable-pull-request-auto-merge.txt + +cat <$graphql_query +mutation automerge { + enablePullRequestAutoMerge(input: {pullRequestId: "$pull_request_node_id", mergeMethod: SQUASH}) { + clientMutationId + } +} +EOF + +json_file=tmp/graphql-payload.json + +jq -n \ + --arg graphql_query "$(cat $graphql_query)" \ + '{query: $graphql_query}' > ${json_file} + + +curl ${curl_custom_flags} \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + ${GITHUB_APIV4_BASE_URL} -d @${json_file} | jq +