I have a Laravel app, everything standard, and as part of my deployment process I need to run npm run production to build assets. I want this as part of my CI/CD, for which I'm using GitHub Actions.
My Actions YML is as follows:
name: Laravel
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- 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 PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Compile assets
run: |
npm install
npm run production
- name: Deploy to Laravel Forge
run: curl ${{ secrets.FORGE_DEPLOYMENT_WEBHOOK }}
This runs fine. However I believe the assets are being compiled in the virtual machine. Once everything has passed I hit the deployment hook for Laravel Forge and my project is deployed. Deployment happens by Forge, it SSH's into the box, git pulls, runs artisan commands. The production compiled assets aren't in the repo, they're stuck in the VM, and disappear once run.
How can I get the assets that are built on the GitHub Actions VM into the Forge deployment? The only way I can think of is to add them via git inside the VM, but that would trigger another run of Actions, so that's not the best method.