Skip to content

Continuous Integration #294

Continuous Integration

Continuous Integration #294

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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: "Install PHP with extensions"
uses: shivammathur/[email protected]
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,
})