Skip to content

Commit

Permalink
Merge pull request #270 from localheinz/feature/merge
Browse files Browse the repository at this point in the history
Enhancement: Restore auto-merge of dependabot pull requests
  • Loading branch information
localheinz authored Nov 8, 2021
2 parents b8f16a1 + eb3b4c1 commit d70f8ca
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 37 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
93 changes: 93 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -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,
})
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit d70f8ca

Please sign in to comment.