Hanuman to the Moon #56
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: Prod in Flight | |
on: | |
pull_request: | |
branches: [ prod ] | |
jobs: | |
test: | |
name: Build and Run Mix Test | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: postgres | |
POSTGRES_PASSWORD: root | |
POSTGRES_USER: postgres | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependecies for build | |
run: sudo apt-get install -y libncurses-dev libtinfo5 | |
- name: Set up Elixir | |
uses: erlef/setup-elixir@885971a72ed1f9240973bd92ab57af8c1aa68f24 | |
with: | |
elixir-version: '1.15.7' # Define the elixir version [required] | |
otp-version: '25' # Define the OTP version [required] | |
- 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 | |
working-directory: ./ | |
run: mix deps.get | |
- name: Run tests | |
env: | |
# use localhost for the host here because we are running the job on the VM. | |
# If we were running the job on in a container this would be postgres | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} | |
working-directory: ./ | |
run: mix test | |
deploy: | |
needs: test | |
name: Build & Deploy to Fly | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: superfly/flyctl-actions@master | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
FLY_APP: vyasa | |
with: | |
args: "deploy" |