From afa4d2754a23cba4d7d92c6c5bc669561966977d Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 3 Apr 2024 16:11:06 -0400 Subject: [PATCH] Initial changes add backport automerge label (#6865) * Add a label to backport PRs in preparation for backport automerge Signed-off-by: Peter Zhu * Small tweaks Signed-off-by: Peter Zhu --------- Signed-off-by: Peter Zhu --- .github/workflows/backport.yml | 10 ++++++++++ .github/workflows/delete_merged_branch.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8f933b2ada..6559b3b15b 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -16,6 +16,7 @@ jobs: # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. if: > github.event.pull_request.merged + && github.repository == 'opensearch-project/documentation-website' && ( github.event.action == 'closed' || ( @@ -38,3 +39,12 @@ jobs: with: github_token: ${{ steps.github_app_token.outputs.token }} head_template: backport/backport-<%= number %>-to-<%= base %> + + - name: Label new backport PR with backport-automerge label + run: | + PR_BRANCH=backport/backport-<%= number %>-to-<%= base %> + PR_NUMBER=`gh pr list -R opensearch-project/documentation-website --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"` + echo "Update Backport PR #$PR_NUMBER on branch $PR_BRANCH with backport-automerge label" + gh issue edit -R opensearch-project/documentation-website $PR_NUMBER --add-label backport-automerge + env: + GH_TOKEN: ${{ steps.github_app_token.outputs.token }} diff --git a/.github/workflows/delete_merged_branch.yml b/.github/workflows/delete_merged_branch.yml index a97d2674e4..f6fc3f2828 100644 --- a/.github/workflows/delete_merged_branch.yml +++ b/.github/workflows/delete_merged_branch.yml @@ -8,7 +8,7 @@ jobs: delete-branch: runs-on: ubuntu-latest if: | - startsWith(github.event.pull_request.head.repo.full_name, 'opensearch-project/documentation-website') && + github.repository == 'opensearch-project/documentation-website' && ${{ !startsWith(github.event.pull_request.head.ref, 'main') }} && ${{ !startsWith(github.event.pull_request.head.ref, '1.') }} && ${{ !startsWith(github.event.pull_request.head.ref, '2.') }} &&