Skip to content

Commit

Permalink
chore: deploy via github action
Browse files Browse the repository at this point in the history
  • Loading branch information
sorax committed Nov 17, 2023
1 parent fcb5eab commit 61323f0
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CD

on:
push:
branches: [main]

env:
OTP_VERSION: "26"
ELIXIR_VERSION: "1.15"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build_test:
name: Build & Test
runs-on: ubuntu-latest

services:
postgres:
image: postgres
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- name: Checkout Repository
uses: actions/checkout@v3

- name: Cache deps
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-deps-
- name: Cache build
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-build-
${{ runner.os }}-mix-
- name: Clean caches on workflow retry
if: github.run_attempt != '1'
run: |
mix deps.clean --all
mix clean
shell: sh

- name: Install Dependencies
run: mix deps.get

- name: Compiles without warnings
run: mix compile --warnings-as-errors

- name: Check Formatting
run: mix format --check-formatted

- name: Run Tests
run: mix test

deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- build_test

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Test

on:
push:
branches: [main]
pull_request:
branches: [main]

Expand Down

0 comments on commit 61323f0

Please sign in to comment.