diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 370c5f4..4fca3d6 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -196,40 +196,3 @@ jobs: - name: "Run tests with phpunit/phpunit" run: "vendor/bin/phpunit --configuration=phpunit.xml" - - merge: - name: "Merge" - - runs-on: "ubuntu-latest" - - needs: - - "coding-standards" - - "static-code-analysis" - - "tests" - - if: > - github.event_name == 'pull_request' && - github.event.pull_request.draft == false && ( - github.event.action == 'opened' || - github.event.action == 'reopened' || - github.event.action == 'synchronize' - ) && ( - (github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'composer(deps-dev)')) || - (github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'github-actions(deps)')) - ) - - steps: - - name: "Merge pull request" - uses: "actions/github-script@v5" - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - script: | - const pullRequest = context.payload.pull_request - const repository = context.repo - - await github.rest.pulls.merge({ - merge_method: "merge", - owner: repository.owner, - pull_number: pullRequest.number, - repo: repository.repo, - }) diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml new file mode 100644 index 0000000..3dde43e --- /dev/null +++ b/.github/workflows/merge.yaml @@ -0,0 +1,93 @@ +# https://docs.github.com/en/actions + +name: "Merge" + +on: # yamllint disable-line rule:truthy + workflow_run: + types: + - "completed" + workflows: + - "Integrate" + +jobs: + merge: + name: "Merge" + + runs-on: "ubuntu-latest" + + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' && + github.actor == 'dependabot[bot]' && ( + startsWith(github.event.workflow_run.head_commit.message, 'composer(deps-dev)') || + startsWith(github.event.workflow_run.head_commit.message, 'github-actions(deps)') + ) + + steps: + - name: "Request review from @ergebnis-bot" + uses: "actions/github-script@v5" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + const pullRequest = context.payload.workflow_run.pull_requests[0] + const repository = context.repo + + const reviewers = [ + "ergebnis-bot", + ] + + await github.rest.pulls.requestReviewers({ + owner: repository.owner, + repo: repository.repo, + pull_number: pullRequest.number, + reviewers: reviewers, + }) + + - name: "Assign @ergebnis-bot" + uses: "actions/github-script@v5" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + const pullRequest = context.payload.workflow_run.pull_requests[0] + const repository = context.repo + + const assignees = [ + "ergebnis-bot", + ] + + await github.rest.issues.addAssignees({ + owner: repository.owner, + repo: repository.repo, + assignees: assignees, + issue_number: pullRequest.number + }) + + - name: "Approve pull request" + uses: "actions/github-script@v5" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + const pullRequest = context.payload.workflow_run.pull_requests[0] + const repository = context.repo + + await github.rest.pulls.createReview({ + event: "APPROVE", + owner: repository.owner, + repo: repository.repo, + pull_number: pullRequest.number, + }) + + - name: "Merge pull request" + uses: "actions/github-script@v5" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + const pullRequest = context.payload.workflow_run.pull_requests[0] + const repository = context.repo + + await github.rest.pulls.merge({ + merge_method: "merge", + owner: repository.owner, + pull_number: pullRequest.number, + repo: repository.repo, + }) diff --git a/README.md b/README.md index 42e7dc5..e3a9fdf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # phpstan-prophecy [![Integrate](https://github.com/Jan0707/phpstan-prophecy/workflows/Integrate/badge.svg)](https://github.com/Jan0707/phpstan-prophecy/actions) +[![Merge](https://github.com/Jan0707/phpstan-prophecy/workflows/Merge/badge.svg)](https://github.com/Jan0707/phpstan-prophecy/actions) [![Latest Stable Version](https://poser.pugx.org/jangregor/phpstan-prophecy/v/stable)](https://packagist.org/packages/jangregor/phpstan-prophecy) [![Total Downloads](https://poser.pugx.org/jangregor/phpstan-prophecy/downloads)](https://packagist.org/packages/jangregor/phpstan-prophecy)