• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Rebase PR
2
3on:
4  repository_dispatch:
5    types: [try-rebase]
6
7jobs:
8  do_rebase:
9    runs-on: ubuntu-20.04
10    environment: mergebot
11    env:
12        GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
13    steps:
14      - name: Checkout repo
15        id: checkout
16        uses: actions/checkout@v2
17        with:
18          fetch-depth: 0
19          token: ${{ secrets.MERGEBOT_TOKEN }}
20
21      - name: Setup Python
22        uses: actions/setup-python@v4
23        with:
24          python-version: '3.8'
25          architecture: x64
26          check-latest: false
27          cache: pip
28      - run: pip install pyyaml==6.0
29
30      - name: Setup committer id
31        run: |
32          git config --global user.email "pytorchmergebot@users.noreply.github.com"
33          git config --global user.name "PyTorch MergeBot"
34
35      - name: Rebase
36        env:
37          GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
38          PR_NUM: ${{ github.event.client_payload.pr_num }}
39          BRANCH: ${{ github.event.client_payload.branch }}
40        run: |
41          set -x
42          if [ -n "${BRANCH}" ]; then
43            python3 .github/scripts/tryrebase.py "${PR_NUM}" --branch "${BRANCH}"
44          else
45            python3 .github/scripts/tryrebase.py "${PR_NUM}"
46          fi
47      - name: Comment on Canceled
48        if: ${{ cancelled() && steps.checkout.outcome == 'success' }}
49        continue-on-error: true
50        env:
51          GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
52          PR_NUM: ${{ github.event.client_payload.pr_num }}
53        run: |
54          set -ex
55          python3 .github/scripts/comment_on_pr.py "${PR_NUM}" "rebase"
56