-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.99 KB
/
migrate-s3.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
---
name: Alfresco s3 Migration
on:
workflow_dispatch:
inputs:
environment:
description: Environment to copy data to
required: true
type: choice
options:
- poc
- dev
- test
- stage
- preprod
- prod
permissions:
contents: read
jobs:
refresh-s3:
name: Refresh S3
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.environment }}
steps:
- uses: actions/[email protected]
- name: Install kubectl
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 --ignore-not-found
- name: S3 migration
working-directory: jobs/migrate-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="${{ vars.MIGRATION_SRC_BUCKET }}"
prefixes=$(kubectl exec $SERVICE_POD_NAME -- aws s3api list-objects-v2 --bucket $SRC_BUCKET --delimiter '/' --query 'CommonPrefixes[*].Prefix' --output text)
# remove all spaces and put one comma between prefixes
cleaned_prefixes=$(echo $prefixes | tr ' ' ',')
DIRS=""
IFS=' '
for prefix in $cleaned_prefixes; do
DIR=$(kubectl exec $SERVICE_POD_NAME -- aws s3api list-objects-v2 --bucket $SRC_BUCKET --prefix "$prefix" --delimiter '/' --query 'CommonPrefixes[*].Prefix' --output text)
#append to DIRS comma separated
if [ -n "$DIR" ]; then
DIRS="${DIRS}${DIR},"
fi
done
DIRS=${DIRS%,}
echo "DIRS: $DIRS"
# helm install migrate-s3 . \
# --set environment=${{ github.event.inputs.environment }} \
# --set directories="{${DIRS}}"
# kubectl wait jobs -l name-prefix=migrate-s3 --for=condition=complete --timeout 10h
- name: Uninstall S3 Refresh chart
run: helm uninstall refresh-s3 --ignore-not-found