Fix Rector rule #727
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of workflow | |
name: PHP CI | |
# Trigger the workflow on push | |
on: | |
- push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: CI | |
steps: | |
######################### | |
### Git ### | |
######################### | |
- uses: actions/checkout@main | |
with: | |
fetch-depth: 0 # Fetch full git history | |
- name: Get Current Branch | |
id: current-branch | |
run: echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT | |
- name: Get Batch Commits Count | |
id: commits-count | |
run: echo "COMMITS_COUNT=$(echo '${{ toJson(github.event.commits) }}' | jq length)" >> $GITHUB_OUTPUT | |
- name: Check Application Image Updates | |
id: application-image-check | |
run: echo "APPLICATION_IMAGE_UPDATED=$(git diff HEAD~${{ steps.commits-count.outputs.COMMITS_COUNT }} --name-only | grep docker/php -q && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT | |
- name: Check Modulite Updates | |
id: application-modulites-check | |
run: echo "MODULITE_UPDATED=$(git diff HEAD~${{ steps.commits-count.outputs.COMMITS_COUNT }} --name-only | grep modulite -q && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT | |
######################### | |
### Docker ### | |
######################### | |
- name: Set Up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
- name: Login to Docker Hub | |
uses: docker/login-action@master | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set APPLICATION_IMAGE Env Variable | |
run: echo "APPLICATION_IMAGE=$(echo "${{ secrets.APPLICATION_IMAGE_REPOSITORY }}:${{ steps.current-branch.outputs.CURRENT_BRANCH != 'master' && steps.application-image-check.outputs.APPLICATION_IMAGE_UPDATED == 'true' && steps.current-branch.outputs.CURRENT_BRANCH || 'latest' }}")" >> $GITHUB_ENV | |
- name: Docker Build && Cache && Push Application Image | |
uses: docker/build-push-action@master | |
with: | |
context: ./docker/php/ | |
builder: ${{ steps.buildx.outputs.name }} | |
push: ${{ steps.application-image-check.outputs.APPLICATION_IMAGE_UPDATED == 'true' }} | |
tags: ${{ env.APPLICATION_IMAGE }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: WWWGROUP=1000 | |
# https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows | |
######################### | |
### Vendor Cache ### | |
######################### | |
- name: Cache Application Composer Dependencies | |
id: application-composer | |
uses: actions/cache@main | |
with: | |
path: vendor | |
key: composer-${{ hashFiles('./composer.lock') }} | |
restore-keys: composer- | |
- name: Cache Laravel Sail Composer Dependencies | |
uses: actions/cache@main | |
id: sail-composer | |
with: | |
path: tools/sail/vendor | |
key: tools-sail-${{ hashFiles('./tools/sail/composer.lock') }} | |
restore-keys: tools-sail- | |
######################### | |
### Vendor Cache Env ### | |
######################### | |
- name: Set APPLICATION_COMPOSER_CACHE Env Variable | |
run: echo "APPLICATION_COMPOSER_CACHE=$(echo "${{ steps.application-composer.outputs.cache-hit == 'true' }}")" >> $GITHUB_ENV | |
- name: Set SAIL_COMPOSER_CACHE Env Variable | |
run: echo "SAIL_COMPOSER_CACHE=$(echo "${{ steps.sail-composer.outputs.cache-hit == 'true' }}")" >> $GITHUB_ENV | |
######################### | |
### Tools Cache ### | |
######################### | |
- name: Set CLEAN_APPLICATION_PHPSTAN_CACHE Env Variable | |
run: echo "CLEAN_APPLICATION_PHPSTAN_CACHE=$(echo "${{ steps.application-modulites-check.outputs.MODULITE_UPDATED == 'true' }}")" >> $GITHUB_ENV | |
- name: Cache PHPStan Analysis | |
uses: actions/cache@main | |
with: | |
path: storage/phpstan | |
key: phpstan-${{ github.sha }} | |
restore-keys: phpstan- | |
- name: Cache PHPInsights Analysis | |
uses: actions/cache@main | |
with: | |
path: storage/phpinsights | |
key: phpinsights-${{ github.sha }} | |
restore-keys: phpinsights- | |
- name: Cache Laravel Pint Analysis | |
uses: actions/cache@main | |
with: | |
path: storage/pint | |
key: pint-${{ github.sha }} | |
restore-keys: pint- | |
- name: Cache PHPCS Analysis | |
uses: actions/cache@main | |
with: | |
path: storage/phpcs | |
key: phpcs-${{ github.sha }} | |
restore-keys: phpcs- | |
- name: Cache Deptrac Analysis | |
uses: actions/cache@main | |
with: | |
path: .deptrac.cache | |
key: deptrac-${{ github.sha }} | |
restore-keys: deptrac- | |
- name: Cache Rector Analysis | |
uses: actions/cache@main | |
with: | |
path: storage/rector/cache | |
key: rector-${{ github.sha }} | |
restore-keys: rector- | |
######################### | |
### CI ### | |
######################### | |
- name: Run CI | |
run: make ci | |
env: | |
APPLICATION_IMAGE: ${{ env.APPLICATION_IMAGE }} | |
######################### | |
### Report ### | |
######################### | |
- name: Upload Coverage to CodeCov.io | |
uses: codecov/codecov-action@main | |
if: ${{ steps.current-branch.outputs.CURRENT_BRANCH == 'master' }} | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: storage/logs/clover.xml | |
fail_ci_if_error: true |