From 7ae0d7d3504f15e7d1f78839d516f02edce81b2b Mon Sep 17 00:00:00 2001 From: Service Binding Operator Bot <111884644+service-binding-operator-bot@users.noreply.github.com> Date: Wed, 12 Oct 2022 19:22:22 +0200 Subject: [PATCH] Add GH workflows for cherry-picking PRs to release branches (#1217) (#1268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pavel MacĂ­k --- .github/workflows/pr-cherry-pick-clean.yaml | 28 +++++++ .github/workflows/pr-cherry-picks.yaml | 84 +++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/pr-cherry-pick-clean.yaml create mode 100644 .github/workflows/pr-cherry-picks.yaml diff --git a/.github/workflows/pr-cherry-pick-clean.yaml b/.github/workflows/pr-cherry-pick-clean.yaml new file mode 100644 index 0000000000..89d08dd35c --- /dev/null +++ b/.github/workflows/pr-cherry-pick-clean.yaml @@ -0,0 +1,28 @@ +name: "Clean cherry pick PR branch" + +on: + pull_request_target: + branches: + - 'release-v**.x' + types: [closed] + +jobs: + delete-cherry-pick-branch: + runs-on: ubuntu-latest + steps: + - name: delete-cherry-pick-branch + uses: actions/github-script@v6 + env: + REPO: ${{ secrets.SBO_CHERRY_PICK_REPO }} + with: + github-token: ${{ secrets.SBO_CHERRY_PICK_BOT_TOKEN }} + script: | + const [owner, repo] = process.env.REPO.split('/'); + const ref = `heads/${context.payload.pull_request.head.ref}`; + const deleteParams = { owner, repo, ref }; + console.log(`Deleting branch: "${ref}"`); + try { + github.rest.git.deleteRef(deleteParams); + } catch(e) { + console.log("Cannot delete branch; error:", e); + } diff --git a/.github/workflows/pr-cherry-picks.yaml b/.github/workflows/pr-cherry-picks.yaml new file mode 100644 index 0000000000..3df1e13ab6 --- /dev/null +++ b/.github/workflows/pr-cherry-picks.yaml @@ -0,0 +1,84 @@ +name: "Cherry pick PR to release branches" + +on: + pull_request_target: + branches: + - master + types: [closed] + +jobs: + cherry_pick_release_v1_1_x: + runs-on: ubuntu-latest + name: Cherry pick into release-v1.1.x branch + if: contains(github.event.pull_request.labels.*.name, 'release/v1.1.x') && github.event.pull_request.merged + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup SSH for cherry-pick repo + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.SBO_CHERRY_PICK_REPO_SSH_PRIVATE_KEY }} + - name: Cherry pick into release-v1.1.x + uses: pmacik/github-cherry-pick-action@main + with: + cherry-pick-repo: ${{ secrets.SBO_CHERRY_PICK_REPO }} + token: ${{ secrets.SBO_CHERRY_PICK_BOT_TOKEN }} + branch: release-v1.1.x + exclude-labels: | + release/v1.2.x + release/v1.3.x + labels: | + cherry-pick + title-prefix: "cherry-pick(release-v1.1.x): " + cherry_pick_release_v1_2_x: + runs-on: ubuntu-latest + name: Cherry pick into release-v1.2.x branch + if: contains(github.event.pull_request.labels.*.name, 'release/v1.2.x') && github.event.pull_request.merged + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup SSH for cherry-pick repo + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.SBO_CHERRY_PICK_REPO_SSH_PRIVATE_KEY }} + - name: Cherry pick into release-v1.2.x + uses: pmacik/github-cherry-pick-action@main + with: + cherry-pick-repo: ${{ secrets.SBO_CHERRY_PICK_REPO }} + token: ${{ secrets.SBO_CHERRY_PICK_BOT_TOKEN }} + branch: release-v1.2.x + exclude-labels: | + release/v1.1.x + release/v1.3.x + labels: | + cherry-pick + title-prefix: "cherry-pick(release-v1.2.x): " + cherry_pick_release_v1_3_x: + runs-on: ubuntu-latest + name: Cherry pick into release-v1.3.x branch + if: contains(github.event.pull_request.labels.*.name, 'release/v1.3.x') && github.event.pull_request.merged + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup SSH for cherry-pick repo + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.SBO_CHERRY_PICK_REPO_SSH_PRIVATE_KEY }} + - name: Cherry pick into release-v1.2.x + uses: pmacik/github-cherry-pick-action@main + with: + cherry-pick-repo: ${{ secrets.SBO_CHERRY_PICK_REPO }} + token: ${{ secrets.SBO_CHERRY_PICK_BOT_TOKEN }} + branch: release-v1.3.x + exclude-labels: | + release/v1.1.x + release/v1.2.x + labels: | + cherry-pick + title-prefix: "cherry-pick(release-v1.3.x): "