-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (202 loc) · 6.87 KB
/
deploy.yaml
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Prod-Deploy
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
APPS:
description: 'Space-separated list of apps to deploy/upgrade, leave empty to deploy everything'
required: false
default: ''
type: string
NAMESPACE:
description: 'Namespace to deploy'
required: true
type: string
DOCKER_REGISTRY:
description: 'Name of the docker registry'
required: false
default: ifx40
type: string
DOCKER_TAG:
description: 'Docker tag to use in the deployment'
required: false
default: 'latest'
type: string
PULL_SECRET_CREDENTIALS:
description: 'Name of the secret in cluster that contains docker registry credentials'
required: false
default: 'regcred'
type: string
CLUSTER:
description: 'Tag of the deployer image with the Kubernetes cluster config'
required: true
type: string
workflow_call:
inputs:
APPS:
description: 'Space-separated list of apps to deploy/upgrade, leave empty to deploy everything'
required: false
default: ''
type: string
NAMESPACE:
description: 'Namespace to deploy'
required: true
type: string
DOCKER_REGISTRY:
description: 'Name of the docker registry'
required: false
default: ifx40
type: string
DOCKER_TAG:
description: 'Docker tag to use in the deployment'
required: false
default: 'latest'
type: string
PULL_SECRET_CREDENTIALS:
description: 'Name of the secret in cluster that contains docker registry credentials'
required: false
default: 'regcred'
type: string
CLUSTER:
description: 'Tag of the deployer image with the Kubernetes cluster config'
required: true
type: string
secrets:
PRIVATE_GITHUB_TOKEN:
description: 'Token to use to clone the repositories'
required: true
S3_URL:
description: 'S3 url to use in the cluster'
required: false
S3_ACCESS_KEY:
description: 'S3 access key to use in the cluster'
required: false
S3_SECRET_KEY:
description: 'S3 secret key to use in the cluster'
required: false
HUB_TOKEN:
description: ''
required: false
GATEWAY_TOKEN:
description: ''
required: false
ALERTA_KEY_DEV:
description: ''
required: false
FACTORY_MONGO_URL_DEV:
description: ''
required: false
USERNAME:
description: ''
required: false
PASSWORD:
description: ''
required: false
ICID_MONGO_URL_DEV:
description: ''
required: false
CLIENT_ID:
description: ''
required: false
CLIENT_SECRET:
description: ''
required: false
EMAIL_URL:
description: ''
required: false
MONGO_URL:
description: ''
required: false
TENANT_ID:
description: ''
required: false
ICID_NAMESPACE:
description: ''
required: false
CREATOR_MONGO_URL_DEV:
description: ''
required: false
TEMPLATE_MONGO_URL_DEV:
description: ''
required: false
jobs:
build:
runs-on: private-2
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_PREFIX: docker.io/ifx40
outputs:
DOCKER_TAG: ${{ steps.build.outputs.NIGHTLY_DOCKER_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: IndustryFusion/IfricPlatform
ref: main
path: IfricPlatform
token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
- name: List directory contents
run: ls -la IfricPlatform
- id: build
name: Build & Push Image
shell: bash
run: |
cd IfricPlatform
export DOCKER_TAG="latest"
NIGHTLY_DOCKER_TAG=nightly-$(date -I)-$(date +%s)
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
docker-compose -f docker-compose.yaml build
docker tag ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG} ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker tag ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG} ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG}
docker push ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-backend:${DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-backend:${NIGHTLY_DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-frontend:${DOCKER_TAG}
docker rmi ${DOCKER_PREFIX}/ifric-platform-frontend:${NIGHTLY_DOCKER_TAG}
echo "NIGHTLY_DOCKER_TAG=${NIGHTLY_DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
clone-repo:
runs-on: private-2
steps:
- uses: actions/checkout@v3
with:
repository: IndustryFusion/GitOpsRepo.git
ref: ${{ github.ref }}
path: GitOpsRepo
#token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
deploy-action:
needs: [clone-repo, build]
runs-on: private-2
container:
image: ifx40/deployer:${{ inputs.CLUSTER }}
options: --user root
volumes:
- ${{ github.workspace }}/GitOpsRepo:/home/deployer/GitOpsRepo
steps:
- name: Deploy
run: |
helm plugin list
#export NAMESPACE="${{ inputs.NAMESPACE }}"
cd /home/deployer/GitOpsRepo/helm
#bash install_operators.sh
APPS="${{ inputs.APPS }}"
LABEL_ARG=""
for app in ${APPS}; do
echo "Adding app: ${app} to deployment"
LABEL_ARG="${LABEL_ARG} -l app=${app}"
done
echo "Deploying with selector: ${LABEL_ARG}"
helmfile ${LABEL_ARG} apply \
--set mainRepo=${{ inputs.DOCKER_REGISTRY }} \
--set mainVersion=${{ needs.build.outputs.DOCKER_TAG }} \
--set namespace=${{ inputs.NAMESPACE }} \
--set pullSecretCredentials=${{ inputs.PULL_SECRET_CREDENTIALS }} \
--set ifric_platform.githubToken="${{ secrets.HUB_TOKEN }}" \
--set ifric_platform.s3AccessKey="${{ secrets.S3_ACCESS_KEY }}" \
--set ifric_platform.s3SecretKey="${{ secrets.S3_SECRET_KEY }}" \
--set ifric_platform.mongoUrl="${{ secrets.CREATOR_MONGO_URL_DEV }}" \
--set ifric_platform_temp.githubToken="${{ secrets.HUB_TOKEN }}" \