Update Github Actions workflow #89
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: Deploy | |
on: | |
push: | |
branches: [main, beta] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
tools: composer:v2 | |
coverage: none | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'npm' | |
cache-dependency-path: npm-shrinkwrap.json | |
- name: Require Vapor CLI | |
run: composer global require laravel/vapor-cli | |
- name: Determine Environment | |
id: determine_environment | |
run: | | |
echo "::set-output name=environment::${{ github.ref == 'refs/heads/main' && 'production' || 'beta' }}" | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install Composer dependencies | |
run: | | |
composer config http-basic.nova.laravel.com "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}" | |
composer install --prefer-dist --no-interaction --no-dev --no-autoloader | |
- name: Generate Optimized Autoloader | |
run: composer dump-autoload --optimize | |
- name: Install NPM Dependencies | |
run: npm ci | |
- name: Build Application | |
run: | | |
npm run build | |
env: | |
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} | |
- name: Configure Ziggy routes | |
run: | | |
if [ "$ENVIRONMENT" = "beta" ]; then | |
APP_URL="beta.wordsearch.games" php artisan ziggy:generate | |
else | |
APP_URL="wordsearch.games" php artisan ziggy:generate | |
fi | |
env: | |
ENVIRONMENT: ${{ format(steps.determine_environment.outputs.environment) }} | |
- name: Create Backend Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: ${{ format(steps.determine_environment.outputs.environment) }} | |
sourcemaps: ./public/js/app.js.map | |
- name: Create Frontend Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_VUE }} | |
with: | |
environment: ${{ format(steps.determine_environment.outputs.environment) }} | |
sourcemaps: ./public/js/app.js.map | |
- name: Deploy Environment | |
run: vapor deploy ${{ steps.determine_environment.outputs.environment }} --commit "${{ github.sha }}" --without-waiting | |
env: | |
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} |