Skip to content

Continuous Integration #289

Continuous Integration

Continuous Integration #289

name: 'Continuous Integration'
on:
create:
pull_request:
push:
branches:
- "*.x"
tags:
- "**"
jobs:
coding-standards:
name: "Coding Standards"
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- 8.0
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP with extensions"
uses: shivammathur/setup-php@2.25.5
with:
coverage: none
extensions: "mbstring, json, mongo"
php-version: ${{ matrix.php-version }}
- name: "Validate composer.json and composer.lock"
run: composer validate --strict
- name: "Cache dependencies installed with composer"
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php${{ matrix.php-version }}-composer-
restore-keys: |
php${{ matrix.php-version }}-composer-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest
- name: "Run localheinz/composer-normalize"
run: composer normalize --dry-run
merge:
name: "Merge"
runs-on: "ubuntu-latest"
needs:
- "coding-standards"
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@v6"
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@v6"
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@v6"
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@v6"
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,
})