Skip to content

Instantly share code, notes, and snippets.

@rorymcdaniel
Created March 26, 2020 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rorymcdaniel/ac6929bd71cdd31d3683b4f54457a60a to your computer and use it in GitHub Desktop.
Save rorymcdaniel/ac6929bd71cdd31d3683b4f54457a60a to your computer and use it in GitHub Desktop.
Starter Github workflow file for Laravel projects
name: CI
on:
push:
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
name: Tests
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, imagick
tools: pecl
coverage: none
- name: Copy ENV Laravel Configuration for CI
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Setup Composer Nova Auth
run: composer config http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_PASSWORD }}
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest
- name: Set app key
run: php artisan key:generate
- name: Install NPM dependencies
run: npm install
- name: Compile assets
run: npm run production
- name: Execute tests
run: vendor/bin/phpunit --verbose
- name: Deploy to staging
if: github.ref == 'refs/heads/develop'
uses: bredmor/vapor-action@master
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
GITHUB_SECRET: ${{ secrets.GITHUB_SECRET }}
with:
args: deploy staging
- name: Deploy to production
if: github.ref == 'refs/heads/master'
uses: bredmor/vapor-action@master
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
GITHUB_SECRET: ${{ secrets.GITHUB_SECRET }}
with:
args: deploy production
@rorymcdaniel
Copy link
Author

Need to set up the following secrets in the repository:

  • VAPOR_API_TOKEN - obtained from the vapor console
  • GITHUB_SECRET - obtain here
  • NOVA_USERNAME - username for laravel nova license
  • NOVA_PASSWORD - API token from nova.laravel.com license page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment