From 9bfc2781ed369e4d908f73250ae4bc4698931749 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:11:58 +0100 Subject: [PATCH 01/17] Check for backports in CI --- .github/workflows/ci-cd.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 250be46bee3..05a08741f7e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -26,6 +26,15 @@ env: permissions: {} jobs: + backport: + runs-on: ubuntu-latest + name: Backport label added? + if: ${{ github.ref == 'refs/heads/master' }} + steps: + - name: Check labels + env: + LABELS: ${{ github.event.pull_request.labels }} + run: echo "$LABELS" | grep -q 'backport' lint: permissions: From a02f7aab6f0eefdb1cb7d57e41ba61f5c94545c5 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:17:33 +0100 Subject: [PATCH 02/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 05a08741f7e..5ac7f8984af 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -29,7 +29,7 @@ jobs: backport: runs-on: ubuntu-latest name: Backport label added? - if: ${{ github.ref == 'refs/heads/master' }} + if: ${{ "$GITHUB_BASE_REF" == 'master' }} steps: - name: Check labels env: From 53fdd5f54a32444ef4e2f9a09c3c5aab16acbd9c Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:20:53 +0100 Subject: [PATCH 03/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 5ac7f8984af..05a08741f7e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -29,7 +29,7 @@ jobs: backport: runs-on: ubuntu-latest name: Backport label added? - if: ${{ "$GITHUB_BASE_REF" == 'master' }} + if: ${{ github.ref == 'refs/heads/master' }} steps: - name: Check labels env: From cf44628823f3189b2b5f52da0947991949a05771 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:31:23 +0100 Subject: [PATCH 04/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 05a08741f7e..907ac42260d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -29,7 +29,7 @@ jobs: backport: runs-on: ubuntu-latest name: Backport label added? - if: ${{ github.ref == 'refs/heads/master' }} + if: ${{ github.base_ref == 'master' }} steps: - name: Check labels env: From 76db874a613cfda8b57747bb4f4ac8488554214b Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:33:37 +0100 Subject: [PATCH 05/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 907ac42260d..a818a3c2624 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -32,9 +32,7 @@ jobs: if: ${{ github.base_ref == 'master' }} steps: - name: Check labels - env: - LABELS: ${{ github.event.pull_request.labels }} - run: echo "$LABELS" | grep -q 'backport' + run: echo "${{ github.event.pull_request.labels }}" | grep -q 'backport' lint: permissions: From 4ecbab01b99a8024d9b6abfa62e0a501cc9f1b95 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 14:47:28 +0100 Subject: [PATCH 06/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a818a3c2624..8b27cc710c2 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -32,7 +32,13 @@ jobs: if: ${{ github.base_ref == 'master' }} steps: - name: Check labels - run: echo "${{ github.event.pull_request.labels }}" | grep -q 'backport' + run: | + for label in "${{ github.event.pull_request.labels }}"; do + case $label in backport*) + exit 0 + esac + done + exit 1 lint: permissions: From 37659a0f1e5ccc56664a95eb882287e8caab847c Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 15:01:19 +0100 Subject: [PATCH 07/17] Create labels.yml --- .github/workflows/labels.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/labels.yml diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 00000000000..73f892e59ca --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,20 @@ +name: Labels +on: + pull_request: + branches: + - 'master' + types: [labeled, opened] + +jobs: + backport: + runs-on: ubuntu-latest + name: Backport label added + steps: + - name: Check labels + run: | + for label in "${{ github.event.pull_request.labels }}"; do + case $label in backport*) + exit 0 + esac + done + exit 1 From 7870e5ac41a5fdd6e344ebb943d6a5e6b3e31f77 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 15:01:37 +0100 Subject: [PATCH 08/17] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8b27cc710c2..250be46bee3 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -26,19 +26,6 @@ env: permissions: {} jobs: - backport: - runs-on: ubuntu-latest - name: Backport label added? - if: ${{ github.base_ref == 'master' }} - steps: - - name: Check labels - run: | - for label in "${{ github.event.pull_request.labels }}"; do - case $label in backport*) - exit 0 - esac - done - exit 1 lint: permissions: From 4b27e2929a64ec90efc1ab899b7b896b03eec506 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 15:08:23 +0100 Subject: [PATCH 09/17] Update labels.yml --- .github/workflows/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 73f892e59ca..e00f97d89e9 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Check labels run: | - for label in "${{ github.event.pull_request.labels }}"; do + for label in ${{ github.event.pull_request.labels }}; do case $label in backport*) exit 0 esac From 3eaa4c0578c86978be77b2889857b392dc5b410e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 15:14:49 +0100 Subject: [PATCH 10/17] Update labels.yml --- .github/workflows/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index e00f97d89e9..69a9dc4eb9d 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -3,7 +3,7 @@ on: pull_request: branches: - 'master' - types: [labeled, opened] + types: [labeled, opened, unlabeled] jobs: backport: From 5d0f182bf1eb6edc971b9ea7f330b7b6bfb43497 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 20:28:15 +0100 Subject: [PATCH 11/17] Update labels.yml --- .github/workflows/labels.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 69a9dc4eb9d..da6b5147021 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -10,11 +10,14 @@ jobs: runs-on: ubuntu-latest name: Backport label added steps: - - name: Check labels - run: | - for label in ${{ github.event.pull_request.labels }}; do - case $label in backport*) - exit 0 - esac - done - exit 1 + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const labels = await github.pulls.listLabelsOnPullRequest({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + if (!labels.data.find(l => l.name.startsWith("backport"))) + process.exit(1); From 2b1884415f89788e8e077f5265e9b1c991410156 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:15:18 +0100 Subject: [PATCH 12/17] Update labels.yml --- .github/workflows/labels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index da6b5147021..63df0de09c5 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -14,10 +14,10 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const labels = await github.pulls.listLabelsOnPullRequest({ + const pr = await github.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number }); - if (!labels.data.find(l => l.name.startsWith("backport"))) + if (!pr.labels.data.find(l => l.name.startsWith("backport"))) process.exit(1); From 1eec3917689d6df865098ee51fe3da14f77f283b Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:23:03 +0100 Subject: [PATCH 13/17] Update labels.yml --- .github/workflows/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 63df0de09c5..a508d57d757 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -14,7 +14,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const pr = await github.pulls.get({ + const pr = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number From 4169e5c58bad8ca208a872f65197279f47e00bd8 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:24:21 +0100 Subject: [PATCH 14/17] Update labels.yml --- .github/workflows/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index a508d57d757..bfd3daed919 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -19,5 +19,5 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number }); - if (!pr.labels.data.find(l => l.name.startsWith("backport"))) + if (!pr.labels.find(l => l.name.startsWith("backport"))) process.exit(1); From df666678553f93e15bf632ab5f324ce4f6877836 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:30:51 +0100 Subject: [PATCH 15/17] Update labels.yml --- .github/workflows/labels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index bfd3daed919..5f5729ec339 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -19,5 +19,6 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number }); - if (!pr.labels.find(l => l.name.startsWith("backport"))) + console.log(pr); + if (!pr.data.labels.find(l => l.name.startsWith("backport"))) process.exit(1); From dab9198bd01cf2422829113d50f576700dc7bb4e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:38:32 +0100 Subject: [PATCH 16/17] Update labels.yml --- .github/workflows/labels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 5f5729ec339..31a9d95b52a 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -19,6 +19,5 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number }); - console.log(pr); if (!pr.data.labels.find(l => l.name.startsWith("backport"))) process.exit(1); From 16756ad67bd0b10ba6ae3ad56a2bac3596b0a00c Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 7 Apr 2024 21:40:56 +0100 Subject: [PATCH 17/17] Update labels.yml --- .github/workflows/labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 31a9d95b52a..a4e961e88af 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -3,7 +3,7 @@ on: pull_request: branches: - 'master' - types: [labeled, opened, unlabeled] + types: [labeled, opened, synchronize, reopened, unlabeled] jobs: backport: