-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (171 loc) · 7.81 KB
/
data-refresh.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
---
name: Alfresco Data Refresh
on:
workflow_dispatch:
inputs:
source_env:
description: Environment to copy data from
required: true
type: choice
options:
- dev
destination_env:
description: Environment to copy data to
required: true
type: choice
options:
- poc
permissions:
contents: read
jobs:
stop-destination-environment:
name: Stop ${{ github.event.inputs.destination_env }} Environment
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.destination_env }}
steps:
- name: Configure kubectl
run: |
echo "${{ secrets.KUBE_CERT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
- name: Stop ${{ github.event.inputs.destination_env }} Environment
run: |
kubectl scale deployment alfresco-content-services-alfresco-cs-repository --replicas=0
kubectl scale deployment alfresco-content-services-alfresco-cs-share --replicas=0
kubectl scale deployment alfresco-content-services-alfresco-search-enterprise-liveindexing --replicas=0
refresh-db:
name: Refresh DB
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.source_env }}
needs: stop-destination-environment
steps:
- uses: actions/[email protected]
- name: Install Kubernetes
uses: azure/[email protected]
with:
version: 'v1.26.0' # default is latest stable
id: kubectl_install
- uses: azure/[email protected]
with:
version: 'v3.15.3' # default is latest (stable)
id: install
- name: Configure kubectl
run: |
echo "${{ secrets.KUBE_CERT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
- name: Uninstall DB Refresh chart
run: helm uninstall refresh-db --ignore-not-found
- name: DB Refresh
working-directory: jobs/refresh-db
run: |
helm install refresh-db . \
--set sourceEnvironment=${{ github.event.inputs.source_env }} \
--set destinationEnvironment=${{ github.event.inputs.destination_env }} \
--set slackWebhookUrl=${{ secrets.SLACK_WEBHOOK_URL }}
refresh-s3:
name: Refresh S3
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.source_env }}
needs: stop-destination-environment
steps:
- uses: actions/[email protected]
- name: Install Kubernetes
uses: azure/[email protected]
with:
version: 'v1.26.0' # default is latest stable
id: kubectl_install
- uses: azure/[email protected]
with:
version: 'v3.15.3' # default is latest (stable)
id: install
- name: Configure kubectl
run: |
echo "${{ secrets.KUBE_CERT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
- name: Uninstall S3 Refresh chart
run: helm uninstall refresh-s3
- name: S3 Refresh
working-directory: jobs/refresh-s3
run: |
set -xeo pipefail
SERVICE_POD_DEPLOYMENT=$(kubectl get deployment -l app=service-pod -o jsonpath="{.items[0].metadata.name}")
SERVICE_POD_NAME=$(kubectl get pod -l app=$SERVICE_POD_DEPLOYMENT -o jsonpath="{.items[0].metadata.name}")
SRC_BUCKET=$(kubectl get secrets s3-bucket-output -o jsonpath='{.data.BUCKET_NAME}' | base64 -d)
DIRS=$(kubectl exec $SERVICE_POD_NAME -- aws s3 ls $SRC_BUCKET | grep -v contentstore | awk -F ' ' '{print $2}' | tr -d '/' | tr '\n' ',')
helm install refresh-s3 . \
--set sourceEnvironment=${{ github.event.inputs.source_env }} \
--set destinationEnvironment=${{ github.event.inputs.destination_env }} \
--set directories="{${DIRS:0:-1}}"
kubectl wait jobs -l name-prefix=refresh-s3 --for=condition=complete --timeout 10h
- name: Uninstall S3 Refresh chart
run: helm uninstall refresh-s3
# wipe-solr-data:
# name: Wipe Solr Data
# runs-on: ubuntu-22.04
# environment:
# name: ${{ github.event.inputs.destination_env }}
# needs: stop-destination-environment
# steps:
# - uses: actions/[email protected]
# - name: Configure kubectl
# run: |
# echo "${{ secrets.KUBE_CERT }}" > ca.crt
# kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
# kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
# kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
# kubectl config use-context ${KUBE_CLUSTER}
# env:
# KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
# KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
# - name: Start Solr Data Wipe Job
# run: |
# kubectl apply -f jobs/wipe-solr-data.yaml
# kubectl wait --timeout 10m --for=condition=complete job/wipe-solr-data
# - name: Delete Refresh Job
# run: kubectl delete job wipe-solr-data
start-destination-environment:
name: Start ${{ github.event.inputs.destination_env }} Environment
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.destination_env }}
needs:
- refresh-db
- refresh-s3
# - wipe-solr-data
steps:
- name: Configure kubectl
run: |
echo "${{ secrets.KUBE_CERT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
- name: Start ${{ github.event.inputs.destination_env }} Environment
run: |
HELM_VALUES=$(helm get values alfresco-content-services -o json)
kubectl scale deployment alfresco-content-services-alfresco-cs-repository --replicas=$(echo $HELM_VALUES | jq '.repository.replicaCount')
kubectl scale deployment alfresco-content-services-alfresco-cs-share --replicas=$(echo $HELM_VALUES | jq '.share.replicaCount')
kubectl scale deployment alfresco-content-services-alfresco-search-enterprise-liveindexing --replicas=1