-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (138 loc) · 5.93 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
---
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-solr --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: 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 DB Refresh Job
run: |
kubectl apply -f jobs/refresh-db.yaml
kubectl wait --timeout 10m --for=condition=complete job/refresh-db
- name: Delete DB Refresh Job
run: kubectl delete job refresh-db
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: 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 S3 Refresh Job
run: |
kubectl apply -f jobs/refresh-s3.yaml
kubectl wait --timeout 10m --for=condition=complete job/refresh-s3
- name: Delete S3 Refresh Job
run: kubectl delete job 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: Stop ${{ github.event.inputs.destination_env }} Environment
run: |
kubectl scale deployment alfresco-content-services-alfresco-cs-repository --replicas=1
kubectl scale deployment alfresco-content-services-alfresco-cs-share --replicas=1
kubectl scale deployment alfresco-content-services-alfresco-search-solr --replicas=1