From 69f3395d9f9de273ffce6cd31ea8aeaa2764fe50 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 29 Jun 2022 12:59:35 +0530 Subject: [PATCH] Fix steps conditions and add rtBot user --- .github/workflows/auto-merge.yml | 19 +++++++++++-------- .../workflows/gutenberg-packages-update.yml | 7 ++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 1aa4e198..44f39642 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -26,10 +26,10 @@ jobs: uses: actions/checkout@v3 - name: Approve and merge the PR - if: > - contains( github.event.workflow_run.head_commit.message, 'version-update:semver-minor' ) || contains( github.event.workflow_run.head_commit.message, 'version-update:semver-patch' ) - run: | - gh pr merge "$PR_NUMBER" --auto --merge --delete-branch + if: | + contains( github.event.workflow_run.head_commit.message, 'version-update:semver-minor' ) || + contains( github.event.workflow_run.head_commit.message, 'version-update:semver-patch' ) + run: gh pr merge "$PR_NUMBER" --auto --merge --delete-branch env: PR_NUMBER: ${{github.event.workflow_run.pull_requests[0].number}} GITHUB_TOKEN: ${{secrets.GH_BOT_TOKEN}} @@ -37,15 +37,18 @@ jobs: gutenberg-packages: name: Gutenberg packages update PR auto-merge runs-on: ubuntu-latest - if: > - ( startsWith(github.event.workflow_run.head_commit.message, 'Update WordPress NPM packages based on Gutenberg release') && endsWith(github.event.workflow_run.head_commit.message, 'github-actions ') ) && ( ${{ github.event.workflow_run.head_commit.author.name }} == 'github-actions' && ${{ github.event.workflow_run.head_commit.author.email }} == 'github-actions@github.com' ) + if: ${{ github.actor == 'rtBot' }} steps: - name: Checkout uses: actions/checkout@v3 - name: Approve and merge the PR - run: | - gh pr merge "$PR_NUMBER" --auto --merge --delete-branch + if: | + startsWith(github.event.workflow_run.head_commit.message, 'Update WordPress NPM packages based on Gutenberg release') && + endsWith(github.event.workflow_run.head_commit.message, format('{0} {1}', 'rtBot', '<43742164+rtBot@users.noreply.github.com>')) && + github.event.workflow_run.head_commit.author.name == 'rtBot' && + github.event.workflow_run.head_commit.author.email == '43742164+rtBot@users.noreply.github.com' + run: gh pr merge "$PR_NUMBER" --auto --merge --delete-branch env: PR_NUMBER: ${{github.event.workflow_run.pull_requests[0].number}} GITHUB_TOKEN: ${{secrets.GH_BOT_TOKEN}} diff --git a/.github/workflows/gutenberg-packages-update.yml b/.github/workflows/gutenberg-packages-update.yml index 5594e051..6569b6d9 100644 --- a/.github/workflows/gutenberg-packages-update.yml +++ b/.github/workflows/gutenberg-packages-update.yml @@ -113,8 +113,8 @@ jobs: - name: Configure git user run: | - git config user.name ${{ secrets.AUTHOR_NAME }} - git config user.email ${{ secrets.AUTHOR_EMAIL }} + git config user.name rtBot + git config user.email '43742164+rtBot@users.noreply.github.com' - name: Check if remote branch exists id: remote-branch run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin "$HEAD_BRANCH" ) ]] && echo "0" || echo "1") @@ -179,7 +179,8 @@ jobs: - name: Add PR reviewers if: steps.pr-create.outputs.pr-url != '' # Add a PR reviewer so that a notification can be sent to the concerned person. - run: gh pr edit "$PR_URL" --add-reviewer ${{ secrets.PR_REVIEWER }} + run: gh pr edit "$PR_URL" --add-reviewer "$REVIEWER_USERNAME" env: GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} PR_URL: ${{ steps.pr-create.outputs.pr-url }} + REVIEWER_USERNAME: thelovekesh