add strategry #31
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 | |
strategy: | |
matrix: | |
include: | |
- elixir: 1.12.0 | |
otp: 24.2 | |
- elixir: 1.13.2 | |
otp: 24.2 | |
lint: lint | |
runs-on: ubuntu-latest | |
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 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Elixir | |
uses: actions/setup-elixir@v1 | |
with: | |
elixir-version: "1.13.0" | |
otp-version: '24.1' | |
- name: Restore dependencies cache | |
uses: actions/cache@v2 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
# - name: Set up Node.js 12.x | |
# uses: actions/setup-node@v1 | |
# with: | |
# node-version: 12.x | |
# - name: Restore npm cache | |
# uses: actions/cache@v2 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: mix deps.get | |
- 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" |