summaryrefslogtreecommitdiffstats
path: root/.github/workflows/automerge_pr.yaml
blob: 599e0f0f274e5c46a876f275e92a2a590c0ad581 (plain) (blame)
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
name: Automerge PR
on:
  schedule:
    - cron: "17 * * * *"   # At minute 17 past every hour
  workflow_dispatch:
concurrency:
  group: ${{ github.workflow }}
  cancel-in-progress: true
env:
  GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
jobs:
  check-pr:
    runs-on: [ self-hosted, auto-provisioned, build-preset-analytic-node]
    timeout-minutes: 70
    steps:
      - name: checkout
        uses: actions/checkout@v5
        with:
          sparse-checkout: |
            .github
            ydb/ci/
      - name: install packages
        shell: bash
        run: |
          pip install PyGithub==2.5.0

      - name: configure
        shell: bash
        run: |
            git config --global user.name YDBot
            git config --global user.email [email protected]
            git config --local github.token ${{ env.GH_TOKEN }}

      - name: run-command
        shell: bash
        env:
          REPO: ${{ github.repository }}
          TOKEN: ${{ env.GH_TOKEN }}
        run: |
          set -euo pipefail
          cd ./ydb/ci/rightlib
          end_time=$(( SECONDS + 55 * 60 ))
          poll_interval=300
          iteration=1

          while (( SECONDS < end_time )); do
            echo "::group::automerge iteration ${iteration}"
            ./automerge.py || echo "::warning::automerge iteration ${iteration} failed with exit code $?"
            echo "::endgroup::"
            remaining=$(( end_time - SECONDS ))
            (( remaining > 0 )) && sleep $(( remaining < poll_interval ? remaining : poll_interval ))
            iteration=$(( iteration + 1 ))
          done