generated from Neoteroi/BlackSheep-Azure-API
-
Notifications
You must be signed in to change notification settings - Fork 6
162 lines (138 loc) · 4.07 KB
/
server.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: ServerCICD
on:
release:
types: [published]
push:
branches:
- dev
- test
- prod
paths:
- ".github/workflows/server.yml"
- "server/**"
pull_request:
branches:
- "*"
paths:
- ".github/workflows/server.yml"
- "server/**"
jobs:
build-ui:
runs-on: ubuntu-18.04
defaults:
run:
working-directory: ui
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 9
submodules: false
- uses: actions/setup-node@v2
with:
node-version: "14.3.0"
- name: Install yarn if necessary
run: |
if ! command -v yarn; then
echo "Missing yarn, installing..."
npm install -g yarn
else
echo "Yarn is already installed."
fi
- name: Install dependencies
run: |
yarn install
- name: Build for production
run: |
yarn build
- name: Zip built package
run: |
cd build
zip -T -r ../../ui-package.zip .
- name: Upload distribution package
uses: actions/upload-artifact@master
with:
name: ui-package
path: ui-package.zip
build-app:
runs-on: ubuntu-18.04
needs: build-ui
defaults:
run:
working-directory: server
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 9
submodules: false
- name: Download a distribution artifact
uses: actions/download-artifact@v2
with:
name: ui-package
- name: Extract built SPA to the app static folder
run: |
unzip ../ui-package.zip -d app/static/
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
id: depcache
with:
path: deps
key: requirements-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
- name: Download dependencies
if: steps.depcache.outputs.cache-hit != 'true'
run: |
pip download --dest=deps -r requirements.txt
- name: Install dependencies
run: |
pip install -U --no-index --find-links=deps deps/*
- name: Run tests
run: |
pytest tests/
- name: Run linters
run: |
flake8 app core data domain tests
black --check app core data domain tests
isort --check-only app core data domain tests
- name: Archive Release
run: |
zip -T -r ../release.zip . -x "venv/*" "__pycache__/*" "**/__pycache__/*" ".mypy_cache/*" ".pytest_cache/*" "deps/*" @
- name: Upload distribution package
uses: actions/upload-artifact@master
with:
name: app-package
path: release.zip
deploy-dev:
needs: build-app
if: github.ref == 'refs/heads/dev' && github.event_name == 'release'
uses: Neoteroi/Torino/.github/workflows/server-env.yml@dev
with:
ENV_NAME: dev
secrets:
AZURE_CREDENTIALS: ${{ secrets.DEV_AZURE_CREDENTIALS }}
DBSA_PASSWORD: ${{ secrets.DEV_DBSA_PASSWORD }}
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}
deploy-test:
needs: build-app
if: github.ref == 'refs/heads/test' && github.event_name == 'release'
uses: Neoteroi/Torino/.github/workflows/server-env.yml@dev
with:
ENV_NAME: test
secrets:
AZURE_CREDENTIALS: ${{ secrets.TEST_AZURE_CREDENTIALS }}
DBSA_PASSWORD: ${{ secrets.TEST_DBSA_PASSWORD }}
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}
deploy-prod:
needs: build-app
if: github.ref == 'refs/heads/prod' && github.event_name == 'release'
uses: Neoteroi/Torino/.github/workflows/server-env.yml@dev
with:
ENV_NAME: prod
secrets:
AZURE_CREDENTIALS: ${{ secrets.PROD_AZURE_CREDENTIALS }}
DBSA_PASSWORD: ${{ secrets.PROD_DBSA_PASSWORD }}
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}