Skip to content

Commit

Permalink
ci: modernize main CI workflow (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
neoncitylights authored Oct 31, 2023
1 parent 80059ec commit 85dbb85
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Composer
name: PHP CI

on:
workflow_dispatch:
Expand All @@ -7,24 +7,28 @@ on:
pull_request:
branches: [ main ]

env:
PHP_LATEST: 8.2

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.1'
- '8.2'

steps:
- uses: actions/checkout@v3

- name: Checkout repository
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: xdebug
tools: composer:v2, phpdoc

php-version: ${{ matrix.php }}
tools: composer:v2
- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
Expand All @@ -33,18 +37,48 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer test

docs:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_LATEST }}
tools: composer:v2, phpdoc
- name: Build documentation
run: composer docs

- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build

ci-success-pr:
runs-on: ubuntu-latest
name: ci-success (PR)
if: ${{ success() && github.event_name == 'pull_request' }}
needs:
- build
steps:
- name: ✅ CI succeeded
run: exit 0

ci-success:
runs-on: ubuntu-latest
name: ci-success
if: ${{ success() && github.event_name == 'push' }}
needs:
- build
- docs
steps:
- name: ✅ CI succeeded
run: exit 0

0 comments on commit 85dbb85

Please sign in to comment.