Skip to content

Commit

Permalink
Merge pull request #348 from Lctrs/fix/merge
Browse files Browse the repository at this point in the history
gha: restore auto-merge of dependabot pull requests
  • Loading branch information
Lctrs committed Aug 9, 2021
2 parents 8ef92d0 + c00cba6 commit 4365ed9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 98 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Expand Up @@ -5,6 +5,7 @@ We are using [GitHub Actions](https://github.com/features/actions) as a continuo
For details, take a look at the following workflow configuration files:

- [`workflows/integrate.yaml`](workflows/integrate.yaml)
- [`workflows/merge.yaml`](workflows/merge.yaml)
- [`workflows/release.yaml`](workflows/release.yaml)
- [`workflows/renew.yaml`](workflows/renew.yaml)
- [`workflows/triage.yaml`](workflows/triage.yaml)
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yaml
Expand Up @@ -5,7 +5,7 @@ version: 2
updates:
- commit-message:
include: "scope"
prefix: "composer"
prefix: "tools"
directory: "/.tools/composer-require-checker"
labels:
- "dependency"
Expand All @@ -17,7 +17,7 @@ updates:

- commit-message:
include: "scope"
prefix: "composer"
prefix: "tools"
directory: "/.tools/infection"
labels:
- "dependency"
Expand Down
4 changes: 0 additions & 4 deletions .github/settings.yml
Expand Up @@ -47,10 +47,6 @@ labels:
color: "0e8a16"
description: ""

- name: "merge"
color: "6f42c1"
description: ""

- name: "question"
color: "cc317c"
description: ""
Expand Down
92 changes: 0 additions & 92 deletions .github/workflows/integrate.yaml
Expand Up @@ -344,95 +344,3 @@ jobs:
run: ".tools/infection/vendor/bin/infection --configuration=infection.json.dist"
env:
STRYKER_DASHBOARD_API_KEY: "${{ secrets.STRYKER_DASHBOARD_API_KEY }}"

merge:
name: "Merge"

runs-on: "ubuntu-latest"

needs:
- "code-coverage"
- "coding-standards"
- "dependency-analysis"
- "mutation-tests"
- "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 == 'Lctrs' && contains(github.event.pull_request.labels.*.name, 'merge'))
)
steps:
- name: "Request review from @lctrs-bot"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"lctrs-bot",
]
await github.pulls.requestReviewers({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
reviewers: reviewers,
})
- name: "Assign @lctrs-bot"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const assignees = [
"lctrs-bot",
]
await github.issues.addAssignees({
assignees: assignees,
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
})
- name: "Approve pull request"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
await github.pulls.createReview({
event: "APPROVE",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})
- name: "Merge pull request"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
await github.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})
95 changes: 95 additions & 0 deletions .github/workflows/merge.yaml
@@ -0,0 +1,95 @@
# 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-20.04"

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, 'tools(deps)') ||
startsWith(github.event.workflow_run.head_commit.message, 'github-actions(deps)')
)
steps:

- name: "Request review from @lctrs-bot"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const reviewers = [
"lctrs-bot",
]
await github.pulls.requestReviewers({
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
reviewers: reviewers,
})
- name: "Assign @lctrs-bot"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
const assignees = [
"lctrs-bot",
]
await github.issues.addAssignees({
owner: repository.owner,
repo: repository.repo,
assignees: assignees,
issue_number: pullRequest.number
})
- name: "Approve pull request"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
await github.pulls.createReview({
event: "APPROVE",
owner: repository.owner,
repo: repository.repo,
pull_number: pullRequest.number,
})
- name: "Merge pull request"
uses: "actions/github-script@v4.0.2"
with:
github-token: "${{ secrets.LCTRS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
await github.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})

0 comments on commit 4365ed9

Please sign in to comment.