How to serve app over https in GitHub Actions?
Hi all,
I'm in the process of developing a CI/CD pipeline for an app, and I'm running into an SSL-related issue when executing my browser tests.
I'm wanting to test the integration with Square Payments. This is working perfectly on local, since I'm serving the local site over SSL and therefore the Square Payments SDK allows rendering of the card payment form. However, when running via GitHub Actions I serve the app with php artisan serve which obviously does not run over SSL, and therefore the card payment form declines to render.
I've done a bunch of research and it seems like Caddy might be the way to go for this, but I can't quite figure out the syntax of the tests.yml file to get this working. Any thoughts?
My current tests.yml workflow file:
name: Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
dusk:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
APP_URL: http://127.0.0.1:8000
APP_ENV: dusk
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
KLAVIYO_PRIVATE_KEY: ${{ secrets.KLAVIYO_PRIVATE_KEY }}
RECAPTCHA_KEY: ${{ secrets.RECAPTCHA_KEY }}
RECAPTCHA_SECRET: ${{ secrets.RECAPTCHA_SECRET }}
ADOBE_CLIENT_ID: ${{ secrets.ADOBE_CLIENT_ID }}
SQUARE_APPLICATION_ID: ${{ secrets.SQUARE_APPLICATION_ID }}
SQUARE_LOCATION_ID: ${{ secrets.SQUARE_LOCATION_ID }}
SQUARE_TOKEN: ${{ secrets.SQUARE_TOKEN }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
# Need to add E to variables_order to ensure $_ENV superglobal is available
ini-values: variables_order=GPCSE
- uses: actions/checkout@v4
# Need this to allow private VCS to be installed
- name: Authenticate Composer with GitHub token
run: composer config --global github-oauth.github.com ${{ secrets.GH_TOKEN }}
- name: Authenticate Nova VCS
run: composer config http-basic.nova.laravel.com ${{ secrets.NOVA_EMAIL }} ${{ secrets.NOVA_LICENSE_KEY }}
- name: Clear Composer cache
run: composer clear-cache
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.dusk.ci', '.env');"
- name: Install Composer dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Clear artisan caches
run: php artisan optimize:clear
- name: Generate key
run: php artisan key:generate
- name: Install NPM dependencies
run: npm install
- name: Compile assets
run: npm run dev
- name: Create sqlite database
run: |
mkdir -p database
touch database/database.sqlite
- name: Install Chrome binaries
run: php artisan dusk:chrome-driver --detect
- name: Start ChromeDriver
run: ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 &
- name: Run Laravel server
run: php artisan serve --host=127.0.0.1 --port=8000 --no-reload &
### Create a reverse proxy for SSL??
- name: Execute browser tests
run: php artisan dusk
- name: Upload failure screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/Browser/screenshots
- name: Upload failure console logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: console
path: tests/Browser/console
- name: Show Laravel logs (on failure)
if: failure()
run: |
echo "📝 Laravel Log:"
cat storage/logs/laravel.log || echo "No laravel.log file found"
Please or to participate in this conversation.