From a799e8817e21ec5d3dc367e6efb1272235510689 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 2 Apr 2024 23:02:51 +0000 Subject: [PATCH 1/2] Add a label to backport PRs in preparation for backport automerge Signed-off-by: Peter Zhu --- .github/workflows/backport.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8f933b2ada..a5a1f8e693 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -38,3 +38,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 peterzhuamazon/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 }} From 55739074116479ec5ad5b22987669044c60530e6 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 2 Apr 2024 23:39:41 +0000 Subject: [PATCH 2/2] Small tweaks Signed-off-by: Peter Zhu --- .github/workflows/backport.yml | 3 ++- .github/workflows/delete_merged_branch.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index a5a1f8e693..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' || ( @@ -42,7 +43,7 @@ jobs: - name: Label new backport PR with backport-automerge label run: | PR_BRANCH=backport/backport-<%= number %>-to-<%= base %> - PR_NUMBER=`gh pr list -R peterzhuamazon/documentation-website --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"` + 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: 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.') }} &&