-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (146 loc) · 6.38 KB
/
build.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
name: 🐋☸️ Build (PR)
on:
pull_request:
branches: [dev, master]
jobs:
build:
runs-on: ubuntu-latest
env:
APP_ID: label-* # specific to backend or client
APP_GROUP: judilibre-prive
APP_HOST: label.judilibre-prive.local
APP_PORT: 443
APP_SCHEME: https
APP_SELF_SIGNED: "true"
APP_KEYWORD: specific # to backend or client
DOCKER_USERNAME: opendatajustice
KUBECONFIG: /home/runner/.kube/config-local-k3s.yaml
KUBE_NAMESPACE: judilibre-prive-local-dev
KUBE_TYPE: k3s
KUBE_ZONE: local
NLP_API_HOST: https://nlp-pseudonymisation.judilibre-prive.local
NLP_API_PORT: 443
ROOT_PATH: label* # specific to backend or client
START_TIMEOUT: 240
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF} | sed 's|^refs/heads/||;' | sed 's/[^a-zA-Z0-9]/-/g')"
id: extract_branch
- name: Init ops dependencies
run: ./scripts/init_deps.sh && ./scripts/check_install.sh
env:
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
- name: 🔙 Get version -- backend
run: echo "##[set-output name=version;]$(./scripts/version.sh)"
id: backend_version
env:
APP_ID: label-backend
- name: 🔙🐋 Check if build is needed -- backend
run: |
echo "##[set-output name=status;]$(./scripts/docker-check.sh || echo build_needed)"
id: backend_check
env:
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
VERSION: ${{ steps.backend_version.outputs.version }}
APP_ID: label-backend
- name: 👤 Get version -- client
run: echo "##[set-output name=version;]$(./scripts/version.sh)"
id: client_version
env:
APP_ID: label-client
- name: 👤🐋 Check if build is needed -- client
run: |
echo "##[set-output name=status;]$(./scripts/docker-check.sh || echo build_needed)"
id: client_check
env:
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
VERSION: ${{ steps.client_version.outputs.version }}
APP_ID: label-client
- name: Use Node.js ${{ matrix.node-version }}
if: (steps.client_check.outputs.status == 'build_needed') || (steps.backend_check.outputs.status == 'build_needed')
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --
if: (steps.client_check.outputs.status == 'build_needed') || (steps.backend_check.outputs.status == 'build_needed')
- run: yarn compile
if: (steps.client_check.outputs.status == 'build_needed') || (steps.backend_check.outputs.status == 'build_needed')
- run: yarn test
if: (steps.client_check.outputs.status == 'build_needed') || (steps.backend_check.outputs.status == 'build_needed')
- run: yarn lint
if: (steps.client_check.outputs.status == 'build_needed') || (steps.backend_check.outputs.status == 'build_needed')
- name: 🔙🐋 Build docker image -- backend
if: (matrix.node-version == '16.x') && (steps.backend_check.outputs.status == 'build_needed')
run: ./scripts/docker-build.sh
env:
APP_ID: label-backend
DOCKER_TARGET: label-backend
VERSION: ${{ steps.backend_version.outputs.version }}
- name: 🔙☸️ Deploy k8s services locally -- backend
if: (matrix.node-version == '16.x') && (steps.backend_check.outputs.status == 'build_needed')
run: ./scripts/deploy_k8s_services.sh
env:
APP_ID: label-backend
API_PORT: 55430
APP_KEYWORD: "true"
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
ROOT_PATH: label/api
VERSION: ${{ steps.backend_version.outputs.version }}
- name: 🔙✅ Execute minimal tests -- backend
if: (matrix.node-version == '16.x') && (steps.backend_check.outputs.status == 'build_needed')
run: |
echo "127.0.0.1 ${APP_HOST}" | sudo tee -a /etc/hosts
kubectl get pods --namespace=${KUBE_NAMESPACE}
kubectl logs service/${APP_ID}-svc --namespace=${KUBE_NAMESPACE}
./scripts/test_minimal.sh
env:
APP_ID: label-backend
APP_KEYWORD: "true"
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
ROOT_PATH: label/api
- name: 👤 Build static app -- client
if: (matrix.node-version == '16.x') && (steps.client_check.outputs.status == 'build_needed')
run: |
export VERSION=$(./scripts/version.sh)
export DOCKER_IMAGE=${DOCKER_USERNAME}/${APP_ID}:${VERSION}
if ! (docker manifest inspect ${DOCKER_IMAGE}); then
yarn buildClient || echo "ugly worakound";
fi
env:
APP_ID: label-client
- name: 👤🐋 Build docker image -- client
if: (matrix.node-version == '16.x') && (steps.client_check.outputs.status == 'build_needed')
run: ./scripts/docker-build.sh
env:
APP_ID: label-client
DOCKER_TARGET: label-client
VERSION: ${{ steps.client_version.outputs.version }}
- name: 👤☸️ Deploy k8s services locally -- client
if: (matrix.node-version == '16.x') && (steps.client_check.outputs.status == 'build_needed')
run: ./scripts/deploy_k8s_services.sh
env:
APP_ID: label-client
API_PORT: 55432
APP_KEYWORD: html
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
ROOT_PATH: label
VERSION: ${{ steps.client_version.outputs.version }}
- name: 👤✅ Execute minimal tests -- client
if: (matrix.node-version == '16.x') && (steps.client_check.outputs.status == 'build_needed')
run: |
echo "127.0.0.1 ${APP_HOST}" | sudo tee -a /etc/hosts
kubectl get pods --namespace=${KUBE_NAMESPACE}
kubectl logs service/${APP_ID}-svc --namespace=${KUBE_NAMESPACE}
./scripts/test_minimal.sh
env:
APP_ID: label-client
APP_KEYWORD: html
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
ROOT_PATH: label