-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (57 loc) · 2.16 KB
/
opensearch-backup.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
---
name: "Alfresco: OpenSearch Backup"
on:
schedule:
- cron: '0 1 * * *' # Run at 1am UTC daily
workflow_dispatch:
inputs:
environment:
description: 'Environment to backup'
required: true
type: choice
options:
- poc
- dev
- test
- stage
- preprod
- prod
jobs:
backup:
name: Backup OpenSearch
runs-on: ubuntu-latest
strategy:
matrix:
environment: ${{ github.event_name == 'schedule' && fromJson('["poc", "dev", "test", "stage"]') || fromJson(format('["{0}"]', github.event.inputs.environment)) }}
environment: ${{ matrix.environment }}-preapproved
steps:
- name: Checkout code
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: Backup OpenSearch
working-directory: jobs/opensearch-backup
run: |
set -xeo pipefail
helm install opensearch-backup . \
--set opensearch.environment=${{ matrix.environment || github.event.inputs.environment }}
kubectl wait job/opensearch-backup --for=condition=complete --timeout=3h
- name: Output job logs
if: always()
run: |
# Get the pod name from the job
POD_NAME=$(kubectl get pods --selector=job-name=opensearch-backup -o jsonpath='{.items[0].metadata.name}')
# Output the logs
echo "=== Backup Job Logs ==="
kubectl logs $POD_NAME
- name: Cleanup
if: always()
run: helm uninstall opensearch-backup --ignore-not-found