-
-
Notifications
You must be signed in to change notification settings - Fork 85
95 lines (93 loc) · 2.8 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
test:
name: Test Elixir ${{ matrix.version }}
runs-on: ubuntu-latest
container: elixir:${{ matrix.version }}-alpine
strategy:
matrix:
include:
- version: "1.14"
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MIX_ENV: test
DB_URL: postgres://postgres:postgres@postgres/keila
steps:
- name: install system packages
run: apk add build-base git tar curl
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
_build
deps
assets/node_modules
key: keila-${{ runner.os }}-elixir-${{ matrix.version }}-${{ hashFiles('mix.lock') }}
- name: mix deps.get
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: mix format --check-formatted
run: mix format --check-formatted
- name: dprint check
run: |
export DPRINT_INSTALL="$HOME/.dprint"
mkdir -p "$DPRINT_INSTALL/bin"
curl -fsSL https://github.com/dprint/dprint/releases/download/0.36.0/dprint-x86_64-unknown-linux-musl.zip -o "$DPRINT_INSTALL/bin/dprint.zip"
unzip "$DPRINT_INSTALL/bin/dprint.zip" -d "$DPRINT_INSTALL/bin/"
chmod +x "$DPRINT_INSTALL/bin/dprint"
export PATH="$PATH:$DPRINT_INSTALL/bin"
dprint check
- name: mix compile --warnings-as-errors
run: mix compile --warnings-as-errors
- name: mix ecto.create && ecto.migrate
run: |
mix ecto.create
mix ecto.migrate
- name: mix test
run: mix test
build:
name: Build and push Docker image
if: github.ref == 'refs/heads/main'
needs:
- test
runs-on: ubuntu-latest
environment: build
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_PAT }}
- uses: docker/build-push-action@v3
with:
context: .
file: ./ops/Dockerfile
tags: |
ghcr.io/pentacent/keila:latest
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache