-
Notifications
You must be signed in to change notification settings - Fork 21.5k
90 lines (85 loc) · 3.38 KB
/
trymerge.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Validate and merge PR
on:
repository_dispatch:
types: [try-merge]
jobs:
do_merge:
name: try_merge_pr_${{ github.event.client_payload.pr_num }}
runs-on: linux.20_04.4x
environment: mergebot
env:
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Checkout repo
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.MERGEBOT_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
check-latest: false
cache: pip
architecture: x64
- run: pip install pyyaml==6.0 rockset==1.0.3
- name: Setup committer id
run: |
git config --global user.email "pytorchmergebot@users.noreply.github.com"
git config --global user.name "PyTorch MergeBot"
- name: Merge PR
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
PR_NUM: ${{ github.event.client_payload.pr_num }}
FORCE: ${{ github.event.client_payload.force}}
COMMENT_ID: ${{ github.event.client_payload.comment_id }}
REBASE: ${{ github.event.client_payload.rebase }}
IGNORE_CURRENT: ${{ github.event.client_payload.ignore_current }}
ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }}
DRCI_BOT_KEY: ${{ secrets.DRCI_BOT_KEY }}
run: |
set -x
if [ -n "${REBASE}" ]; then
# attempt to rebase, if it fails then comment on the PR that it failed
if ! python3 .github/scripts/tryrebase.py "${PR_NUM}" --branch "${REBASE}"; then
python3 .github/scripts/comment_on_pr.py "${PR_NUM}" "merge"
exit 0
fi
git checkout main
git fetch -p
# give github some time between the push and start workflows so that Github's messages
# on the PR appear in chronological order (timing issues can shuffle them around)
sleep 60
fi
if [ -n "${FORCE}" ]; then
if [ -n "${COMMENT_ID}" ]; then
python3 .github/scripts/trymerge.py --force --comment-id "${COMMENT_ID}" "${PR_NUM}"
else
python3 .github/scripts/trymerge.py --force "${PR_NUM}"
fi
elif [ -n "${IGNORE_CURRENT}" ]; then
if [ -n "${COMMENT_ID}" ]; then
python3 .github/scripts/trymerge.py --ignore-current --comment-id "${COMMENT_ID}" "${PR_NUM}"
else
python3 .github/scripts/trymerge.py --ignore-current "${PR_NUM}"
fi
elif [ -n "${COMMENT_ID}" ]; then
python3 .github/scripts/trymerge.py --comment-id "${COMMENT_ID}" "${PR_NUM}"
else
python3 .github/scripts/trymerge.py "${PR_NUM}"
fi
- name: Comment on Canceled
if: ${{ cancelled() && steps.checkout.outcome == 'success' }}
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
PR_NUM: ${{ github.event.client_payload.pr_num }}
run: |
set -x
python3 .github/scripts/comment_on_pr.py "${PR_NUM}" "merge"
# We want newer merge commands to supercede old ones
concurrency:
group: try-merge-${{ github.event.client_payload.pr_num }}
cancel-in-progress: true