]> git.puffer.fish Git - mirror/frr.git/commitdiff
github: Add rebase label on PR if it's > 50 commits behind 13429/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 3 May 2023 20:17:58 +0000 (23:17 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 9 May 2023 06:37:23 +0000 (09:37 +0300)
The idea is to catch some PRs and rerun them in CI to avoid merging PRs that
are based on the stale base branch and causes issues afterwards.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
.github/workflows/behind-base.yml [new file with mode: 0644]

diff --git a/.github/workflows/behind-base.yml b/.github/workflows/behind-base.yml
new file mode 100644 (file)
index 0000000..16b6434
--- /dev/null
@@ -0,0 +1,28 @@
+name: Add rebase label if the branch is > 50 commits behind
+
+on:
+  pull_request_target:
+    types: [synchronize, opened, reopened, labeled, unlabeled]
+
+jobs:
+  behind:
+    if: github.repository == 'frrouting/frr'
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      pull-requests: write
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          ref: ${{ github.event.pull_request.head.sha }}
+          fetch-depth: 0
+      - name: Set custom variables
+        id: vars
+        run: |
+          echo "behind_by=$(git log --oneline origin/${{ github.base_ref }} ^${{ github.event.pull_request.head.sha }} | wc -l)" >> $GITHUB_OUTPUT
+      - name: Add rebase label if needed
+        if: ${{ steps.vars.outputs.behind_by > 50 }}
+        uses: actions-ecosystem/action-add-labels@v1
+        with:
+          labels: rebase