-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauto-merge-syncs.yaml
52 lines (46 loc) · 1.57 KB
/
auto-merge-syncs.yaml
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
48
49
50
51
52
on: pull_request
jobs:
merge:
name: "Auto merge workflow syncs"
runs-on: "ubuntu-latest"
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false && (
github.event.action == 'opened' ||
github.event.action == 'reopened' ||
github.event.action == 'synchronize'
) && (
github.actor == 'gh-file-sync[bot]'
)
steps:
- name: Merge pull request for ${{ github.event.client_payload.ReleaseBranchName }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.pulls.merge({
merge_method: "rebase",
owner: context.repo.owner,
pull_number: context.payload.pull_request.number,
repo: context.repo.repo,
})
- name: Delete merged pull request branch
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const refExists = await github.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "heads/${{ github.head_ref }}",
}).then(() => true, error => {
if (error.status === 404) return false
throw error
})
if (refExists) {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "heads/${{ github.head_ref }}",
})
}