Skip to content

Merge pull request #15 from NoCompromises/standards-updates #30

Merge pull request #15 from NoCompromises/standards-updates

Merge pull request #15 from NoCompromises/standards-updates #30

Workflow file for this run

name: Default Project CI
on: push
jobs:
tests:
runs-on: ubuntu-22.04
env:
PROJECT_NAME: my-project
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup default environment
run: cp .env.example .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker images
uses: docker/bake-action@v3
with:
load: true
files: |
docker-compose.yml
targets: |
php-fpm
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
- name: Build Docker containers and start them
run: docker compose up -d mysql mysql-test php-fpm --wait --no-build
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Install PHP Dependencies
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_ALLOW_SUPERUSER=1 composer install --no-interaction --no-scripts --no-progress --prefer-dist"
- name: Failure debug
if: ${{ failure() }}
run: |
docker ps -a
docker logs --timestamps "$PROJECT_NAME-php-fpm"
docker logs --timestamps "$PROJECT_NAME-mysql"
docker inspect "$PROJECT_NAME-php-fpm"
docker inspect "$PROJECT_NAME-mysql"
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('package-lock.json') }}
- name: Set up Volta to manage Node/Npm versions
uses: volta-cli/action@v4
- name: Install JS dependencies
run: npm install && npm run build
- name: Cache routes
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan route:cache
- name: Cache views
run: docker exec "$PROJECT_NAME-php-fpm" ./artisan view:cache
- name: Cache Larastan result cache
uses: actions/cache@v3
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache
restore-keys: | # prefix allows it to use previous cache as starting point
phpstan-result-cache-
- name: Cache php-cs-fixer result cache
uses: actions/cache@v3
with:
path: .php-cs-fixer.cache
key: "php-cs-fixer-result-cache-${{ github.run_id }}" # always unique key - always writes a new cache
restore-keys: | # prefix allows it to use previous cache as starting point
php-cs-fixer-result-cache-
- name: Run CI tools
run: docker exec "$PROJECT_NAME-php-fpm" /usr/bin/env sh -c "COMPOSER_MEMORY_LIMIT=-1 composer ci"
- name: Check logs if you need to debug a failing test
if: ${{ failure() }}
run: docker exec "$PROJECT_NAME-php-fpm" cat storage/logs/laravel.log
- name: Deploy to staging if develop branch
if: github.ref == 'refs/heads/develop'
run: curl -s ${{ secrets.ENVOYER_STAGING_TRIGGER }}
- name: Deploy to prod if main branch
if: github.ref == 'refs/heads/main'
run: curl -s ${{ secrets.ENVOYER_PROD_TRIGGER }}