Skip to content

Merge pull request #23 from NickMous/feature/fix-not-kept-form-values #24

Merge pull request #23 from NickMous/feature/fix-not-kept-form-values

Merge pull request #23 from NickMous/feature/fix-not-kept-form-values #24

Workflow file for this run

name: Deploy Laravel App to production
env:
PUBLIC_PATH: "/var/www/html/nl/CycleQuest"
BUILD_PATH: "/var/www/html/nl/"
BUILD_REPO: "CycleQuest"
on:
push:
branches: [main]
jobs:
laravel-tests:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.11
env:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: test
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: "8.3"
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Composer Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Install NPM Dependencies
run: npm install
- name: Run build
run: npm run build
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via Pest
env:
DB_CONNECTION: mariadb
DB_DATABASE: test
DB_USERNAME: test_user
DB_PASSWORD: test_password
run: vendor/bin/pest
deploy:
needs: laravel-tests
runs-on: ubuntu-latest
steps:
- name: Activate maintenance mode 🛠️
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.SSHPORT }}
script: |
cd ${{ env.PUBLIC_PATH }}
(php artisan down --secret="bypass-nick" --refresh="15") || true
- name: Deploy code to production 🚀
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.SSHPORT }}
script: |
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
cd ${{ env.PUBLIC_PATH }}
git pull
composer install --optimize-autoloader --no-dev --no-interaction --prefer-dist
php artisan clear-compiled
npm ci
php artisan migrate --force
npm run build
php artisan optimize
- name: Deactivate maintenance mode 🛠️
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.SSHPORT }}
script: |
cd ${{ env.PUBLIC_PATH }}
php artisan up