From 2f43cb02c88a9c6a43092d28cf9b7b121ab133cd Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 13 Nov 2024 13:09:54 +0000 Subject: [PATCH 1/5] Externalise backport action --- .github/workflows/backport-5-0.yml | 40 ------------------ .github/workflows/backport-5-1.yml | 40 ------------------ .github/workflows/backport-5-2.yml | 40 ------------------ .github/workflows/backport-5-3.yml | 40 ------------------ .github/workflows/backport-5-4.yml | 40 ------------------ .github/workflows/backport-5-5.yml | 40 ------------------ .github/workflows/backport-workflow.yml | 44 +++++++++++++++++++ .github/workflows/backport.yml | 56 ++++++++++++------------- .github/workflows/forwardport.yml | 38 +++-------------- 9 files changed, 75 insertions(+), 303 deletions(-) delete mode 100644 .github/workflows/backport-5-0.yml delete mode 100644 .github/workflows/backport-5-1.yml delete mode 100644 .github/workflows/backport-5-2.yml delete mode 100644 .github/workflows/backport-5-3.yml delete mode 100644 .github/workflows/backport-5-4.yml delete mode 100644 .github/workflows/backport-5-5.yml create mode 100644 .github/workflows/backport-workflow.yml diff --git a/.github/workflows/backport-5-0.yml b/.github/workflows/backport-5-0.yml deleted file mode 100644 index 3dffc7647..000000000 --- a/.github/workflows/backport-5-0.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to version 5.0 -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.0'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.0"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-5-1.yml b/.github/workflows/backport-5-1.yml deleted file mode 100644 index 5964dfc32..000000000 --- a/.github/workflows/backport-5-1.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to latest maintenance branch -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.1'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.1"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-5-2.yml b/.github/workflows/backport-5-2.yml deleted file mode 100644 index 47f5aed75..000000000 --- a/.github/workflows/backport-5-2.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to the latest maintenance branch (v/5.2) -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.2'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.2"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-5-3.yml b/.github/workflows/backport-5-3.yml deleted file mode 100644 index 8c281af0a..000000000 --- a/.github/workflows/backport-5-3.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to the latest maintenance branch (v/5.3) -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.3'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.3"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-5-4.yml b/.github/workflows/backport-5-4.yml deleted file mode 100644 index c6ff5061a..000000000 --- a/.github/workflows/backport-5-4.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to the 5.4.0 branch -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.4'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.4"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-5-5.yml b/.github/workflows/backport-5-5.yml deleted file mode 100644 index d3daef370..000000000 --- a/.github/workflows/backport-5-5.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Backport changes to the 5.5.0 branch -on: - push: - branches: - - main -jobs: - backport: - strategy: - matrix: - branch: ['v/5.5'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4.1.4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to 5.5"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push diff --git a/.github/workflows/backport-workflow.yml b/.github/workflows/backport-workflow.yml new file mode 100644 index 000000000..c80374ee9 --- /dev/null +++ b/.github/workflows/backport-workflow.yml @@ -0,0 +1,44 @@ +name: Backport changes + +on: + workflow_call: + inputs: + label: + description: Triggering label to check for + required: true + type: string + target-branch: + required: true + type: string + +jobs: + backport: + runs-on: ubuntu-latest + + steps: + - name: Check PR for backport label + id: check_pr_labels + uses: shioyang/check-pr-labels-on-push-action@v1.0.12 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + labels: ${{ inputs.label }} + + - name: See result + run: echo "${{ steps.check_pr_labels.outputs.result }}" + + - name: Checkout repository + if: ${{ steps.check_pr_labels.outputs.result == 'true' }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout maintenance branch and cherry-pick + if: ${{ steps.check_pr_labels.outputs.result == 'true' }} + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + git fetch + git checkout ${{ inputs.target-branch }} + git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA + git push \ No newline at end of file diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 2ad888348..7fda6a91a 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -4,37 +4,33 @@ on: branches: - main jobs: - backport: - strategy: - matrix: - branch: ['v/5.0', 'v/5.1', 'v/5.2', 'v/5.3', 'v/5.4', 'v/5.5'] + get-maintenance-branches: runs-on: ubuntu-latest + outputs: + branches: "['5.0', '5.1', '5.2', '5.3', '5.4', '5.5']" steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - run: exit 0 - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for backport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["backport to all versions"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" + backport-to-all-branch: + needs: get-maintenance-branches + strategy: + fail-fast: true + matrix: + branch: ${{ fromJSON(needs.get-maintenance-branches.outputs.branches) }} + uses: ./.github/workflows/backport-workflow.yml + with: + label: '["backport to all versions"]' + target-branch: v/${{ matrix.branch }} + secrets: inherit - - name: Checkout maintenance branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push + backport-to-specified-branch: + needs: get-maintenance-branches + strategy: + fail-fast: true + matrix: + branch: ${{ fromJSON(needs.get-maintenance-branches.outputs.branches) }} + uses: ./.github/workflows/backport-workflow.yml + with: + label: '["backport to ${{ matrix.branch }}"]' + target-branch: v/${{ matrix.branch }} + secrets: inherit diff --git a/.github/workflows/forwardport.yml b/.github/workflows/forwardport.yml index 48f007ddc..619e0ae2f 100644 --- a/.github/workflows/forwardport.yml +++ b/.github/workflows/forwardport.yml @@ -5,36 +5,8 @@ on: - v/* jobs: forwardport: - strategy: - matrix: - branch: ['main'] - runs-on: ubuntu-latest - steps: - - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up git config - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - - - name: Check PR for forwardport label - id: check_pr_labels - uses: shioyang/check-pr-labels-on-push-action@v1.0.12 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - labels: '["forwardport to snapshot"]' - - - name: See result - run: echo "${{ steps.check_pr_labels.outputs.result }}" - - - name: Checkout branch and cherry-pick - if: ${{ steps.check_pr_labels.outputs.result == 'true' }} - run: | - git fetch - git checkout ${{ matrix.branch }} - git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push + uses: ./.github/workflows/backport-workflow.yml + with: + label: '["forwardport to snapshot"]' + target-branch: main + secrets: inherit From 127c3b8796d9b55343b6ba13edadf1c18622ec41 Mon Sep 17 00:00:00 2001 From: Jack Green Date: Wed, 13 Nov 2024 15:08:24 +0000 Subject: [PATCH 2/5] Update backport.yml --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 7fda6a91a..e874d1c94 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,4 +1,4 @@ -name: Backport changes to all maintenance branches +name: Backport changes to maintenance branches on: push: branches: From 695b4bf22e4df7683e2061c0bfdbcd12017f711a Mon Sep 17 00:00:00 2001 From: Jack Green Date: Wed, 13 Nov 2024 15:26:32 +0000 Subject: [PATCH 3/5] Amended supported versions --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index e874d1c94..3a0113f87 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -7,7 +7,7 @@ jobs: get-maintenance-branches: runs-on: ubuntu-latest outputs: - branches: "['5.0', '5.1', '5.2', '5.3', '5.4', '5.5']" + branches: "['5.3', '5.4', '5.5']" steps: - run: exit 0 From 688283ab27b28767e648182317c075111c48cd1f Mon Sep 17 00:00:00 2001 From: Jack Green Date: Wed, 13 Nov 2024 23:00:13 +0000 Subject: [PATCH 4/5] Add blank line --- .github/workflows/backport-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport-workflow.yml b/.github/workflows/backport-workflow.yml index c80374ee9..3209b0e6a 100644 --- a/.github/workflows/backport-workflow.yml +++ b/.github/workflows/backport-workflow.yml @@ -41,4 +41,4 @@ jobs: git fetch git checkout ${{ inputs.target-branch }} git cherry-pick -x --strategy=recursive -X theirs $GITHUB_SHA - git push \ No newline at end of file + git push From d6759976613cf1507effc5560a5b8b02e472d691 Mon Sep 17 00:00:00 2001 From: Jack Green Date: Thu, 14 Nov 2024 07:33:24 +0000 Subject: [PATCH 5/5] Fix param names and matrix failing --- .github/workflows/backport-workflow.yml | 5 ++--- .github/workflows/backport.yml | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backport-workflow.yml b/.github/workflows/backport-workflow.yml index 3209b0e6a..73651545c 100644 --- a/.github/workflows/backport-workflow.yml +++ b/.github/workflows/backport-workflow.yml @@ -3,8 +3,7 @@ name: Backport changes on: workflow_call: inputs: - label: - description: Triggering label to check for + label-to-check-for: required: true type: string target-branch: @@ -21,7 +20,7 @@ jobs: uses: shioyang/check-pr-labels-on-push-action@v1.0.12 with: github-token: ${{ secrets.GITHUB_TOKEN }} - labels: ${{ inputs.label }} + labels: ${{ inputs.label-to-check-for }} - name: See result run: echo "${{ steps.check_pr_labels.outputs.result }}" diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 3a0113f87..e23e0bdd1 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -14,23 +14,23 @@ jobs: backport-to-all-branch: needs: get-maintenance-branches strategy: - fail-fast: true + fail-fast: false matrix: branch: ${{ fromJSON(needs.get-maintenance-branches.outputs.branches) }} uses: ./.github/workflows/backport-workflow.yml with: - label: '["backport to all versions"]' + label-to-check-for: '["backport to all versions"]' target-branch: v/${{ matrix.branch }} secrets: inherit backport-to-specified-branch: needs: get-maintenance-branches strategy: - fail-fast: true + fail-fast: false matrix: branch: ${{ fromJSON(needs.get-maintenance-branches.outputs.branches) }} uses: ./.github/workflows/backport-workflow.yml with: - label: '["backport to ${{ matrix.branch }}"]' + label-to-check-for: '["backport to ${{ matrix.branch }}"]' target-branch: v/${{ matrix.branch }} secrets: inherit