Trigger Prod from Feature #66
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: | |
runs-on: ubuntu-22.04 # Use a specific version for stability | |
name: Build OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} && Run Mix Test | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: postgres | |
POSTGRES_PASSWORD: root | |
POSTGRES_USER: postgres | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
matrix: | |
otp: ['26.2'] | |
elixir: ['1.16.3'] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Pin to a specific version for stability | |
- name: Install dependencies for build | |
run: sudo apt-get update && sudo apt-get install -y libncurses-dev libtinfo5 | |
- name: Setup Elixir and OTP | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{matrix.otp}} | |
elixir-version: ${{matrix.elixir}} | |
- name: Restore dependencies cache | |
uses: actions/cache@v4 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Run tests | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} | |
run: mix test | |
deploy: | |
needs: test | |
name: Build & Deploy to Fly | |
runs-on: ubuntu-22.04 # Use a specific version for stability | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Pin to a specific version for stability | |
- name: Deploy to Fly.io | |
uses: superfly/flyctl-actions@master | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
FLY_APP: vyasa | |
with: | |
args: "deploy" |