first commit #1
This file contains hidden or 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: Tests | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0.21 | |
env: | |
MYSQL_DATABASE: posts-test | |
MYSQL_ROOT_PASSWORD: root | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" | |
steps: | |
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e | |
with: | |
php-version: '8.1' | |
- uses: actions/checkout@v3 | |
- name: Copy .env | |
run: | | |
cd api | |
cp .env.ci .env | |
- name: Install Dependencies | |
run: | | |
cd api | |
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Generate key | |
run: | | |
cd api | |
php artisan key:generate | |
- name: Directory Permissions | |
run: | | |
cd api | |
chmod -R 777 storage bootstrap/cache | |
- name: phpstan | |
run: | | |
cd api | |
./vendor/bin/phpstan analyse --memory-limit=1G | |
- name: phpinsights | |
run: | | |
cd api | |
php artisan insights --no-interaction --min-quality=90 --min-complexity=90 --min-architecture=90 --min-style=90 --ansi --format=github-action | |
- name: Run tests | |
run: | | |
cd api | |
php artisan test | |
- name: Copy SSH key | |
run: | | |
echo "${{ secrets.SSH_KEY }}" >> ./id_rsa | |
chmod 600 id_rsa | |
- name: Run deploy script | |
run: | | |
scp -C -o StrictHostKeyChecking=no -i ./id_rsa ./deployment/bin/deploy.sh ${{ secrets.SSH_CONNECTION_TESTING }}:/home/martin/deploy.sh | |
scp -C -o StrictHostKeyChecking=no -i ./id_rsa ./id_rsa ${{ secrets.SSH_CONNECTION_TESTING }}:/home/martin/.ssh/id_rsa | |
ssh -tt -o StrictHostKeyChecking=no -i ./id_rsa ${{ secrets.SSH_CONNECTION_TESTING }} "chown martin:martin /home/martin/deploy.sh && chmod +x /home/martin/deploy.sh" | |
ssh -tt -o StrictHostKeyChecking=no -i ./id_rsa ${{ secrets.SSH_CONNECTION_TESTING }} "/home/martin/deploy.sh ${{ secrets.MYSQL_PASSWORD }}" |