Skip to content

Update README.md

Update README.md #56

Workflow file for this run

name: 🚀 Deploy
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
fix-php:
runs-on: ubuntu-latest
name: 🛠 Fix PHP formatting
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
coverage: none
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: 🔍 Read .env
run: grep -E 'PHP_VERSION' .env.prod >> $GITHUB_ENV
- uses: ramsey/composer-install@v3
- run: mkdir -p .tmp/rector
- uses: actions/cache@v3
with:
path: .tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-
- name: Run rector
run: vendor/bin/rector --ansi
- run: mkdir -p .tmp/pint
- name: Cache Pint
uses: actions/cache@v3
with:
path: .tmp/pint.cache
key: ${{ runner.os }}-pint-${{ github.run_id }}
restore-keys: ${{ runner.os }}-pint-
- name: Run pint
run: ./vendor/bin/pint
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix code style
skip_fetch: true
test:
name: Run all tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
coverage: none
- name: 🔍 Read .env
run: (grep -E 'PHP_VERSION' .env.prod >> $GITHUB_ENV && cp .env.ci .env)
- uses: ramsey/composer-install@v3
- name: 🖱️ Set Node v${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: 📥 Install front-end dependencies
run: npm ci --ignore-scripts
- name: 🔨 build front-end
run: npm run build
- name: 🐘 Run PHP tests
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_CONNECTION: mysql
DB_DATABASE: test_db
DB_USERNAME: user
DB_PASSWORD: password
run: (php artisan key:generate && php artisan migrate && php artisan test)
- uses: actions/upload-artifact@v1
if: failure()
with:
name: laravel-failure-artifact
path: storage/logs/laravel.log
deploy:
needs:
- fix-php
- test
name: Deploy
runs-on: ubuntu-latest
env:
BUILD_SOURCE_DIR: .
BUILD_ARTIFACT_STAGING_DIR: build/
BUILD_ARTIFACT_DESTINATION_DIR: /domains/ysbrand.dev/deployment/uploads/
steps:
- name: 🛎️ Checkout project
uses: actions/checkout@v3
- name: 🔍 Read .env
run: grep -E 'PHP_VERSION|NODE_VERSION' .env.prod >> $GITHUB_ENV
- name: 🖱️ Setup PHP v${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
- uses: ramsey/composer-install@v3
with:
composer-options: "--ignore-platform-reqs --optimize-autoloader --prefer-dist --no-dev"
- name: 🖱️ Set Node v${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: 📥 Install front-end dependencies
run: npm ci --ignore-scripts
- name: 🔨 build front-end
run: npm run build
- name: 🗑️ Remove storage directory
run: rm -rf storage
- name: 📁 Create build directory
run: mkdir ${{ env.BUILD_ARTIFACT_STAGING_DIR }}
- name: 🗄️ ZIP Build
uses: TheDoctor0/zip-release@0.6.1
with:
filename: ${{ env.BUILD_ARTIFACT_STAGING_DIR }}build.zip
path: ${{ env.BUILD_SOURCE_DIR }}
exclusions: 'storage/* build/* node_modules/*'
- name: ➗ Calculate checksum
run: openssl md5 ${{ env.BUILD_ARTIFACT_STAGING_DIR }}build.zip | cut -d" " -f2 > ${{ env.BUILD_ARTIFACT_STAGING_DIR }}checksum.txt
- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@4.1.0
with:
server: ${{ secrets.HOST_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ${{ env.BUILD_ARTIFACT_STAGING_DIR }}
server-dir: ${{ env.BUILD_ARTIFACT_DESTINATION_DIR }}