From b762592b5a56763f5d4cc475e16d63997575f299 Mon Sep 17 00:00:00 2001 From: Chenyang Ji Date: Wed, 19 Jun 2024 14:30:08 -0700 Subject: [PATCH] add backport github workflow Signed-off-by: Chenyang Ji --- .github/workflows/backport.yml | 35 ++++++++++++++++++++ .github/workflows/delete_backport_branch.yml | 20 +++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/backport.yml create mode 100644 .github/workflows/delete_backport_branch.yml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 00000000..f8a9e0da --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,35 @@ +name: Backport +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backport: + name: Backport + runs-on: ubuntu-latest + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) + permissions: + contents: write + pull-requests: write + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - name: Backport \ No newline at end of file diff --git a/.github/workflows/delete_backport_branch.yml b/.github/workflows/delete_backport_branch.yml new file mode 100644 index 00000000..39b5b342 --- /dev/null +++ b/.github/workflows/delete_backport_branch.yml @@ -0,0 +1,20 @@ +## +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +## + +name: Delete merged branch of the backport PRs +on: + pull_request: + types: + - closed + +jobs: + delete-branch: + runs-on: ubuntu-latest + if: startsWith(github.event.pull_request.head.ref,'backport/') + steps: + - name: Delete merged branch + uses: SvanBoxel/delete-merged-branch@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file