fix CI/CD #192
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: Run Test and PHP Stan | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: false | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: laravel | |
ports: | |
- 3306/tcp | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: π Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.1' | |
- name: Start mysql service | |
run: sudo /etc/init.d/mysql start | |
- name: Verify unittest DB exists | |
run: mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "SHOW DATABASES" | |
- name: π¦ Install Composer Dependencies | |
run: composer install --no-progress --prefer-dist --optimize-autoloader | |
- name: π Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: π Execute tests (Unit and Feature tests) via PHPUnit | |
run: php artisan test --env=testing --stop-on-failure | |
- name: π Execute PHP Stan | |
run: ./vendor/bin/phpstan analyse | |
deploy: | |
name: Deploy | |
needs: test | |
if: success() | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- name: π Deploy updates | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
cd /home/anton/www/clip-zone.com | |
make deploy |