Skip to content

Commit

Permalink
Enhancement: Restore auto-merge of dependabot pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 5, 2021
1 parent be66696 commit 544d8af
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 93 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
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/triage.yaml`](workflows/triage.yaml)

## Coding Standards
Expand Down
4 changes: 0 additions & 4 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ labels:
color: "0e8a16"
description: ""

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

- name: "question"
color: "cc317c"
description: ""
Expand Down
89 changes: 0 additions & 89 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,92 +24,3 @@ jobs:
config_file: ".yamllint.yaml"
file_or_dir: "."
strict: true

merge:
name: "Merge"

runs-on: "ubuntu-latest"

needs:
- "coding-standards"

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, 'github-actions(deps)')) ||
(github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge'))
)
steps:
- name: "Request review from @ergebnis-bot"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"ergebnis-bot",
]
await github.pulls.requestReviewers({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
reviewers: reviewers,
})
- name: "Assign @ergebnis-bot"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"ergebnis-bot",
]
await github.issues.addAssignees({
assignees: reviewers,
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
})
- name: "Approve pull request"
uses: "actions/[email protected]"
if: "github.actor != 'ergebnis-bot'"
with:
github-token: "${{ secrets.ERGEBNIS_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/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_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,
})
92 changes: 92 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 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, 'github-actions(deps)')
)
steps:
- name: "Request review from @ergebnis-bot"
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_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.ERGEBNIS_BOT_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.ERGEBNIS_BOT_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.ERGEBNIS_BOT_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 @@
# .github

[![Integrate](https://github.com/ergebnis/.github/workflows/Integrate/badge.svg?branch=main)](https://github.com/ergebnis/.github/actions)
[![Merge](https://github.com/ergebnis/.github/workflows/Merge/badge.svg?branch=main)](https://github.com/ergebnis/.github/actions)

Provides community health files for the [@ergebnis](https://github.com/ergebnis) organization.

Expand Down

0 comments on commit 544d8af

Please sign in to comment.