Alfresco: OpenSearch Backup #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |