-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (112 loc) · 3.3 KB
/
ci_cd-multi_project.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Multi-project CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
setup:
name: Set up projects
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set matrix
id: set-matrix
run: |
MATRIX=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
echo "::set-output name=matrix::$MATRIX"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
build:
name: Build and test "${{ matrix.project.directory }}"
needs: [ setup ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
services:
db:
image: postgres:11
ports: [ '5432:5432' ]
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: ${{ matrix.project.directory }}
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-elixir@885971a72ed1f9240973bd92ab57af8c1aa68f24
with:
elixir-version: '1.11.3'
otp-version: '23.2'
- 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
run: mix deps.get
- name: Check formatting
run: mix format --check-formatted
- name: Compile code
env:
MIX_ENV: test
run: mix compile
- name: Analyze code
if: matrix.project.analyze
env:
MIX_ENV: test
run: mix credo --strict
- name: Run tests
env:
MIX_ENV: test
run: mix test
- name: Generate coverage report
if: matrix.project.cover
env:
MIX_ENV: test
run: mix coveralls.json
- name: Upload coverage to Codecov
if: matrix.project.cover
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
flags: ${{ matrix.project.flag }}
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
name: Deploy release "${{ matrix.project.directory }}"
needs: [ setup, build ]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
if: matrix.project.deploy
with:
fetch-depth: 0
ref: main
- name: Set up Python
if: matrix.project.deploy
uses: actions/setup-python@v2
with:
python-version: 3.8.1
- name: Deploying to Gigalixir
if: matrix.project.deploy
uses: mhanberg/[email protected]
with:
APP_SUBFOLDER: ${{ matrix.project.directory }}
GIGALIXIR_APP: ${{ matrix.project.app }}
GIGALIXIR_CLEAN: true
GIGALIXIR_USERNAME: ${{ secrets.GIGALIXIR_USERNAME }}
GIGALIXIR_PASSWORD: ${{ secrets.GIGALIXIR_PASSWORD }}
MIGRATIONS: true
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}