Skip to content

Deploying through Github Actions Fails #12721

@electrictomcat

Description

@electrictomcat

Bug description

While deploying in Github Actions using Vapor I run into issues where all artisan commands are now looking for the database so that Statamic can do it's Statamic\Sites\Sites::__construct() but there is no database present in the build runner environment.

How to reproduce

Create any statamic application or add it to an application.
Deploy that application through Vapor initially.
Setup a Github Action like this to deploy to vapor:

steps:
  - name: Setup PHP
    uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
    with:
      php-version: '8.4'

  - name: Checkout code
    uses: actions/checkout@v3

  - name: Setup Node
    uses: actions/setup-node@v3
    with:
      node-version: 22

  - name: Copy .env
    run: php -r "file_exists('.env') || copy('.env.example', '.env');"
  - name: Install Dependencies
    run: composer install --no-interaction --prefer-dist --optimize-autoloader
  - name: Generate key
    run: php artisan key:generate
  - name: Directory Permissions
    run: chmod -R 777 storage bootstrap/cache
  - name: Setup pages
    run: |
      npm install
      npm run prod
  - name: Install Vapor
    env:
      VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
    run: composer global require laravel/vapor-cli --update-with-dependencies
  - name: Publish Nova Assets
    run: |
      php artisan nova:publish --ansi
      php artisan telescope:publish --ansi
  - name: Deploy Environment
    env:
      VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
    run: vapor deploy production --commit="${{ github.event.head_commit.id }}" --message="${{ github.event.head_commit.message }}"

And it will fail to install dependencies

Logs

❯ composer install --no-interaction --prefer-dist --optimize-autoloader
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Database\QueryException

  Database file at path [/Users/tommichael/Code/eagle-med/database/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: select exists (select 1 from sqlite_master where name = 'sites' and type = 'table') as "exists")

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

  1   [internal]:0
      Statamic\Sites\Sites::__construct()

  2   [internal]:0
      Illuminate\Foundation\Application::{closure:Illuminate\Foundation\Application::boot():1131}(Object(Statamic\Stache\ServiceProvider), "Statamic\Stache\ServiceProvider")

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Environment

Environment
Application Name: Eagle Medical Inc
Laravel Version: 11.46.1
PHP Version: 8.4.10
Composer Version: 2.8.12
Environment: local
Debug Mode: ENABLED
URL: eagle-med.test
Maintenance Mode: OFF
Timezone: America/Los_Angeles
Locale: en

Cache
Config: NOT CACHED
Events: CACHED
Routes: CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / daily, flare
Mail: smtp
Queue: redis
Session: database

Pulse
Enabled: ENABLED
Version: v1.4.3

Livewire
Livewire: v3.6.4

Statamic
Addons: 1
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.66.0 PRO

Statamic Addons
statamic/eloquent-driver: 4.32.0

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Fieldsets: eloquent
Form Submissions: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: file
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent

Installation

Existing Laravel app

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions