Skip to content

Deploy PostgresCluster to dlvr #21

Deploy PostgresCluster to dlvr

Deploy PostgresCluster to dlvr #21

name: Openshift DB deploy/update
run-name: Deploy PostgresCluster to ${{ inputs.ENVIRONMENT_NAME}}
on:
workflow_dispatch:
inputs:
ENVIRONMENT_NAME:
required: true
type: choice
options:
- dev
- qa
- dlvr
- test
- prod
- tools
NAMESPACE:
required: true
type: choice
options:
- e980f4-dev
- e980f4-test
- e980f4-prod
- e980f4-tools
jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT_NAME }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: copy crunchydb files
run: mkdir staging && cp -r crunchy-postgres/charts/crunchy-postgres staging/crunchy-postgres
- name: Fill properties files
uses: cschleiden/replace-tokens@v1.2
with:
files: staging/**/*
env:
LICENSE_PLATE: 'e980f4'
#Vault path is different for prod than all other environments
VAULT_RESOURCE: ${{ inputs.NAMESPACE == 'e980f4-prod' && 'prod' || 'nonprod' }}
ENV: ${{ inputs.ENVIRONMENT_NAME }}
DB_STORAGE: ${{ vars.DB_STORAGE }}
DB_MAX_CPU: ${{ vars.DB_MAX_CPU }}
DB_MAX_MEMORY: ${{ vars.DB_MAX_MEMORY}}
DB_REPLICAS: ${{ vars.DB_INSTANCE_HA_REPLICAS }}
DB_BACKUP_VOLUME_SIZE: ${{ vars.DB_BACKUP_VOLUME_SIZE }}
BOUNCER_REPLICAS: ${{ vars.DB_LOADBALANCER_HA_REPLICAS}}
- name: install helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
#Explicit install of oc cli tool
- name: Install oc
uses: redhat-actions/oc-installer@v1
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{secrets.openshift_server_url}}
openshift_token: ${{secrets.openshift_token}}
namespace: ${{ inputs.NAMESPACE }}
- name: zip and install helm chart
run: |
cd staging && tar -czvf crunchy-postgres.tar.gz crunchy-postgres
export STATUS_OUT=$(helm status crunchy-postgres-${{inputs.ENVIRONMENT_NAME}} 2>&1 >/dev/null)
if [[ $STATUS_OUT == *"not found"* ]]; then
echo "Attempting helm install"
helm install crunchy-postgres-${{inputs.ENVIRONMENT_NAME}} ./crunchy-postgres.tar.gz
exit 0
else
echo "Attempting helm upgrade"
helm upgrade crunchy-postgres-${{inputs.ENVIRONMENT_NAME}} ./crunchy-postgres.tar.gz
exit 0
fi