Skip to content

Instantly share code, notes, and snippets.

@marcelobbfonseca
Created September 23, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelobbfonseca/1d8b1c5e073f752c1b69a7794cde49dd to your computer and use it in GitHub Desktop.
Save marcelobbfonseca/1d8b1c5e073f752c1b69a7794cde49dd to your computer and use it in GitHub Desktop.
Working Github actions CI example for Laravel+Vue+Postgis project
name: LaravuePostgisCIExample
on:
push:
branches:
- master
- stage
pull_request:
branches:
- stage
jobs:
container-job:
runs-on: ubuntu-18.04
# runs all of the steps inside the specified continer rather than on the VM host.
# Because of this the network configuration changes from host based network to a container network.
container:
image: php:7.3-alpine
services:
postgres:
image: mdillon/postgis:10
env:
POSTGRES_DB: postgresdb
POSTGRES_USER: postgresuser
POSTGRES_PASSWORD: secret
POSTGRES_HOST: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
env:
# use postgres for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be localhost
POSTGRES_HOST: postgres
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
# Runs all steps on the VM
# The service containers will use host port binding instead of container networking so you access them via localhost rather than the service name
vm-job:
runs-on: ubuntu-18.04
services:
postgres:
image: mdillon/postgis:10
env:
POSTGRES_DB: postgresdb
POSTGRES_USER: postgresuser
POSTGRES_PASSWORD: secret
POSTGRES_HOST: postgres
ports:
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Run PHPUnit tests
run: vendor/bin/phpunit --no-coverage
env:
# use localhost for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be postgres
DB_HOST: localhost
DB_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
# run: docker exec -i canie-api vendor/bin/phpunit
- name: Install npm dependencies
run: npm ci
- name: Run Mix
run: npm run production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment