Update composer and php #257
Workflow file for this run
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: Build, Test & Deploy | |
on: | |
pull_request: | |
branches: [ master ] | |
push: | |
branches: [ master ] | |
env: | |
DB_DATABASE: esac | |
DB_USERNAME: mysql | |
DB_PASSWORD: mysql | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-latest | |
environment: Build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache PHP dependencies | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Cache Node dependencies | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
username: esacci | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
- name: Setup MySQL | |
uses: mirromutth/[email protected] | |
with: | |
host port: 3306 | |
container port: 3306 | |
mysql version: 8.0 | |
mysql database: ${{ env.DB_DATABASE }} | |
mysql user: ${{ env.DB_USERNAME }} | |
mysql password: ${{ env.DB_PASSWORD }} | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | |
- name: Install Dependencies | |
run: | | |
composer install --prefer-dist --no-progress --no-suggest | |
npm ci | |
- name: PHP artisan setup | |
run: | | |
php artisan key:generate | |
php artisan storage:link | |
php artisan migrate --seed | |
php artisan serve & | |
- name: NPM build | |
run: npm run prod | |
- name: Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
run: vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.xml | |
- name: Upload to codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.xml | |
fail_ci_if_error: true | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: esac/website:${{ github.run_number }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: laravel-tests | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- name: Deploy via SSH | |
uses: D3rHase/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
user: ic | |
private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
command: ./update.sh website "${{ github.run_number }}" "${{ github.actor }}" "${{ github.event.head_commit.message }}" "${{ github.event.head_commit.timestamp }}" "${{ github.ref }}" |