WIP #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fly CI/CD | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
test: | |
name: Build and test | |
runs-on: ubuntu-22.04 | |
services: | |
db: | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
image: postgres:11 | |
ports: ['5432:5432'] | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- pair: | |
elixir: 1.14.0 | |
otp: 24.3 | |
lint: lint | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: 1.14.0 | |
otp-version: 24.3 | |
- name: Install Dependencies | |
run: mix deps.get --only test | |
- name: Restore dependencies cache | |
uses: actions/cache@v2 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Setup Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: npm install and test | |
run: | | |
cd assets | |
yarn install | |
- name: Setup test server | |
run: MIX_ENV=test mix ecto.create | |
- name: Run Test migration | |
run: MIX_ENV=test mix ecto.migrate | |
- name: Run tests | |
run: mix test | |
deploy: | |
name: Deploy app | |
needs: test | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
runs-on: ubuntu-latest | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: superfly/[email protected] | |
with: | |
args: "deploy" |