From e78353d74c80799f69f85852ac0b004d3e1c8bc0 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 11:15:51 -0600 Subject: [PATCH 1/6] addition of the auto-approve bot PRs workflow Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/auto_approve_pr.yml diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml new file mode 100644 index 00000000000..af39880d654 --- /dev/null +++ b/.github/workflows/auto_approve_pr.yml @@ -0,0 +1,19 @@ +name: Auto Approval of Bot Pull Requests +on: + pull_request: + types: [opened, reopened] + +jobs: + auto_approve: + name: Approve Pull Request + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Approve Pull Request + if: ${{ github.event.pull_request.user.login == 'vitess-bot[bot]' }} && ${{ github.event.pull_request.draft == 'false' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr review ${{ github.event.pull_request.number }} --approve \ No newline at end of file From bfbd8a5cf66b69860f31c09a7587c336c9f8ee51 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 11:23:39 -0600 Subject: [PATCH 2/6] fix Approve Pull Request step condition Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml index af39880d654..ecaec85c640 100644 --- a/.github/workflows/auto_approve_pr.yml +++ b/.github/workflows/auto_approve_pr.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v3 - name: Approve Pull Request - if: ${{ github.event.pull_request.user.login == 'vitess-bot[bot]' }} && ${{ github.event.pull_request.draft == 'false' }} + if: github.event.pull_request.user.login == 'vitess-bot[bot]' && github.event.pull_request.draft == 'false' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 68b94272e5e9b4d16351804314a09b1657291670 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 11:41:46 -0600 Subject: [PATCH 3/6] wip - use local bot for testing Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml index ecaec85c640..99780aa57aa 100644 --- a/.github/workflows/auto_approve_pr.yml +++ b/.github/workflows/auto_approve_pr.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v3 - name: Approve Pull Request - if: github.event.pull_request.user.login == 'vitess-bot[bot]' && github.event.pull_request.draft == 'false' + if: github.event.pull_request.user.login == 'bot-vitess[bot]' && github.event.pull_request.draft == 'false' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 03b4d1ab412a1d16a3e0a5c8f24b51a3ac25de45 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 12:16:08 -0600 Subject: [PATCH 4/6] proper condition Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml index 99780aa57aa..5d38e721f98 100644 --- a/.github/workflows/auto_approve_pr.yml +++ b/.github/workflows/auto_approve_pr.yml @@ -12,8 +12,9 @@ jobs: uses: actions/checkout@v3 - name: Approve Pull Request - if: github.event.pull_request.user.login == 'bot-vitess[bot]' && github.event.pull_request.draft == 'false' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr review ${{ github.event.pull_request.number }} --approve \ No newline at end of file + if [[ "${{github.event.pull_request.user.login}}" == "bot-vitess[bot]" ]] && [[ "${{github.event.pull_request.draft}}" == "false" ]]; then + gh pr review ${{ github.event.pull_request.number }} --approve + fi From 95de5aec3192670e148cee058e27244d6635296d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 13:29:09 -0600 Subject: [PATCH 5/6] revert test code Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml index 5d38e721f98..8636c549497 100644 --- a/.github/workflows/auto_approve_pr.yml +++ b/.github/workflows/auto_approve_pr.yml @@ -15,6 +15,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if [[ "${{github.event.pull_request.user.login}}" == "bot-vitess[bot]" ]] && [[ "${{github.event.pull_request.draft}}" == "false" ]]; then + if [[ "${{github.event.pull_request.user.login}}" == "vitess-bot[bot]" ]] && [[ "${{github.event.pull_request.draft}}" == "false" ]]; then gh pr review ${{ github.event.pull_request.number }} --approve fi From f90bc3dccbced266e9de92fd1dfa70882ab47585 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Tue, 24 Oct 2023 14:44:40 -0600 Subject: [PATCH 6/6] add code comment and fix step name Signed-off-by: Florent Poinsard --- .github/workflows/auto_approve_pr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto_approve_pr.yml b/.github/workflows/auto_approve_pr.yml index 8636c549497..552f1ec2e68 100644 --- a/.github/workflows/auto_approve_pr.yml +++ b/.github/workflows/auto_approve_pr.yml @@ -5,16 +5,19 @@ on: jobs: auto_approve: - name: Approve Pull Request + name: Auto Approve Pull Request runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - - name: Approve Pull Request + - name: Auto Approve Pull Request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # here we are checking that the PR has been created by the vitess-bot[bot] account and that it is not a draft + # if there is a merge conflict in the backport, the PR will always be created as a draft, meaning we can rely + # on checking whether or not the PR is a draft if [[ "${{github.event.pull_request.user.login}}" == "vitess-bot[bot]" ]] && [[ "${{github.event.pull_request.draft}}" == "false" ]]; then gh pr review ${{ github.event.pull_request.number }} --approve fi