Skip to content

Commit

Permalink
Extract merge pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 28, 2020
1 parent 65a7e70 commit 35d0385
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 82 deletions.
83 changes: 1 addition & 82 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -100,7 +100,7 @@ jobs:
run: composer phpstan

- name: "Run psalm"
run: vendor/bin/psalm --config=psalm.xml --diff --diff-methods --shepherd --show-info=false --stats --threads=4
run: vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4

- name: "Run phpmd"
run: composer phpmd
Expand Down Expand Up @@ -237,84 +237,3 @@ jobs:

- name: "Run mutation tests with pcov and infection/infection"
run: ./infection

merge:
name: "Merge"

runs-on: "ubuntu-latest"

needs:
- "coding-standards"
- "static-code-analysis"
- "tests"
- "code-coverage"
- "mutation-tests"

if: >
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
contains(github.event.pull_request.labels.*.name, 'automerge')
steps:
- name: "Request review from @nucleos-bot"
uses: "actions/github-script@v3"
with:
github-token: "${{ secrets.NUCLEOS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"nucleos-bot",
]
await github.pulls.requestReviewers({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
reviewers: reviewers,
})
- name: "Assign @nucleos-bot"
uses: "actions/github-script@v3"
with:
github-token: "${{ secrets.NUCLEOS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"nucleos-bot",
]
await github.issues.addAssignees({
assignees: reviewers,
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
})
- name: "Approve pull request"
uses: "actions/github-script@v3"
if: "github.actor != 'nucleos-bot'"
with:
github-token: "${{ secrets.NUCLEOS_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@v3"
with:
github-token: "${{ secrets.NUCLEOS_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,
})
81 changes: 81 additions & 0 deletions .github/workflows/merge.yml
@@ -0,0 +1,81 @@
on:
pull_request:
types: [opened, synchronize, reopened, labeled]

name: "Merge"

jobs:
merge:
name: "Merge"

runs-on: "ubuntu-latest"

if: >
success() &&
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
contains(github.event.pull_request.labels.*.name, 'automerge')
steps:
- name: "Request review from @nucleos-bot"
uses: "actions/github-script@v3"
with:
github-token: ${{ secrets.NUCLEOS_BOT_TOKEN }}
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"nucleos-bot",
]
await github.pulls.requestReviewers({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
reviewers: reviewers,
})
- name: "Assign @nucleos-bot"
uses: "actions/github-script@v3"
with:
github-token: ${{ secrets.NUCLEOS_BOT_TOKEN }}
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo
const reviewers = [
"nucleos-bot",
]
await github.issues.addAssignees({
assignees: reviewers,
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
})
- name: "Approve pull request"
uses: "actions/github-script@v3"
if: "github.actor != 'nucleos-bot'"
with:
github-token: ${{ secrets.NUCLEOS_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@v3"
with:
github-token: ${{ secrets.NUCLEOS_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,
})

0 comments on commit 35d0385

Please sign in to comment.