-
Notifications
You must be signed in to change notification settings - Fork 5.9k
47 lines (47 loc) · 1.55 KB
/
on_pull_request_synchronized.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Pull request synchronized
on:
pull_request_target:
types:
- synchronize
branches:
- "master"
- "releases/**"
jobs:
disable-automerge:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const prQuery = `query PullRequest($owner: String!, $repo: String!, $pullRequestNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pullRequestNumber) {
id
autoMergeRequest {
enabledAt
}
}
}
}`;
const prVariables = {
owner: context.repo.owner,
repo: context.repo.repo,
pullRequestNumber: context.issue.number
}
const prResult = await github.graphql(prQuery, prVariables)
if (!prResult.repository.pullRequest.autoMergeRequest) {
console.log('Auto merge is not enabled')
return
}
const automergeQuery = `mutation DisablePullRequestAutoMerge($pullRequestId: ID!) {
disablePullRequestAutoMerge(input: {pullRequestId: $pullRequestId}) {
pullRequest {
id
}
}
}`;
const automergeVariables = {
pullRequestId: prResult.repository.pullRequest.id
}
const result = await github.graphql(automergeQuery, automergeVariables)
console.log(result)