Created
February 18, 2021 04:23
-
-
Save owenconti/369ef975d5f1d5dad430f022f448874e to your computer and use it in GitHub Desktop.
GitHub Action to Deploy Laravel Vapor Apps
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: Build | |
on: [push, workflow_dispatch] | |
jobs: | |
build-php: | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_USER: root | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: laravel | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
name: Build PHP | |
runs-on: ubuntu-latest | |
container: lorisleiva/laravel-docker:7.4 | |
steps: | |
- uses: actions/checkout@v2 | |
- run: composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts | |
- run: ./vendor/bin/phpcs --standard=./phpcs.xml --extensions=php app --warning-severity=0 | |
- run: npm ci | |
- run: npm run dev | |
- name: Configure application | |
run: | | |
cp .env.ci .env | |
php artisan cache:clear | |
php artisan config:clear | |
php artisan key:generate | |
- run: ./vendor/bin/phpunit --colors=never | |
deploy: | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' | |
name: Deploy application | |
runs-on: ubuntu-latest | |
container: lorisleiva/laravel-docker:7.4 | |
needs: [build-php] | |
env: | |
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} | |
VAPOR_ENV: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} | |
steps: | |
- uses: actions/checkout@v2 | |
- run: composer install --no-dev --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts | |
- run: ./vendor/bin/vapor deploy ${{ env.VAPOR_ENV }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment