1name: Validate and merge PR 2 3on: 4 repository_dispatch: 5 types: [try-merge] 6 7jobs: 8 do_merge: 9 name: try_merge_pr_${{ github.event.client_payload.pr_num }} 10 runs-on: linux.20_04.4x 11 environment: mergebot 12 permissions: 13 id-token: write 14 env: 15 GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 16 steps: 17 - name: Checkout repo 18 id: checkout 19 uses: actions/checkout@v3 20 with: 21 fetch-depth: 0 22 token: ${{ secrets.MERGEBOT_TOKEN }} 23 24 - name: Setup Python 25 uses: actions/setup-python@v4 26 with: 27 python-version: '3.8' 28 check-latest: false 29 cache: pip 30 architecture: x64 31 - run: pip install pyyaml==6.0 rockset==1.0.3 32 33 - name: Setup committer id 34 run: | 35 git config --global user.email "pytorchmergebot@users.noreply.github.com" 36 git config --global user.name "PyTorch MergeBot" 37 - name: Merge PR 38 shell: bash 39 env: 40 GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }} 41 PR_NUM: ${{ github.event.client_payload.pr_num }} 42 FORCE: ${{ github.event.client_payload.force}} 43 COMMENT_ID: ${{ github.event.client_payload.comment_id }} 44 REBASE: ${{ github.event.client_payload.rebase }} 45 IGNORE_CURRENT: ${{ github.event.client_payload.ignore_current }} 46 ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }} 47 DRCI_BOT_KEY: ${{ secrets.DRCI_BOT_KEY }} 48 GITHUB_RUN_ID: ${{ github.run_id }} 49 run: | 50 set -x 51 if [ -n "${REBASE}" ]; then 52 # attempt to rebase, if it fails then comment on the PR that it failed 53 if ! python3 .github/scripts/tryrebase.py "${PR_NUM}" --branch "${REBASE}"; then 54 python3 .github/scripts/comment_on_pr.py "${PR_NUM}" "merge" 55 exit 0 56 fi 57 git checkout main 58 git fetch -p 59 # give github some time between the push and start workflows so that Github's messages 60 # on the PR appear in chronological order (timing issues can shuffle them around) 61 sleep 60 62 fi 63 if [ -n "${FORCE}" ]; then 64 if [ -n "${COMMENT_ID}" ]; then 65 python3 .github/scripts/trymerge.py --force --comment-id "${COMMENT_ID}" "${PR_NUM}" 66 else 67 python3 .github/scripts/trymerge.py --force "${PR_NUM}" 68 fi 69 elif [ -n "${IGNORE_CURRENT}" ]; then 70 if [ -n "${COMMENT_ID}" ]; then 71 python3 .github/scripts/trymerge.py --ignore-current --comment-id "${COMMENT_ID}" "${PR_NUM}" 72 else 73 python3 .github/scripts/trymerge.py --ignore-current "${PR_NUM}" 74 fi 75 elif [ -n "${COMMENT_ID}" ]; then 76 python3 .github/scripts/trymerge.py --comment-id "${COMMENT_ID}" "${PR_NUM}" 77 else 78 python3 .github/scripts/trymerge.py "${PR_NUM}" 79 fi 80 - name: Comment on Canceled 81 if: ${{ cancelled() && steps.checkout.outcome == 'success' }} 82 continue-on-error: true 83 env: 84 GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }} 85 PR_NUM: ${{ github.event.client_payload.pr_num }} 86 run: | 87 set -x 88 python3 .github/scripts/comment_on_pr.py "${PR_NUM}" "merge" 89 90 - name: configure aws credentials 91 uses: aws-actions/configure-aws-credentials@v3 92 continue-on-error: true 93 with: 94 role-to-assume: arn:aws:iam::308535385114:role/upload_to_ossci_raw_job_status 95 aws-region: us-east-1 96 97 - name: Upload merge record to s3 98 if: always() 99 continue-on-error: true 100 uses: seemethere/upload-artifact-s3@v5 101 with: 102 s3-bucket: ossci-raw-job-status 103 s3-prefix: merges/${{ github.repository }}/${{ github.event.client_payload.pr_num }}/${{ github.event.client_payload.comment_id }}/${{ github.run_id }} 104 path: merge_record.json 105 106# We want newer merge commands to supercede old ones 107concurrency: 108 group: try-merge-${{ github.event.client_payload.pr_num }} 109 cancel-in-progress: true 110