Deploy PostgresCluster to dev #58
Workflow file for this run
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: 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: | |
- a12541-dev | |
- a12541-test | |
- a12541-prod | |
- a12541-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/[email protected] | |
with: | |
files: staging/**/* | |
env: | |
LICENSE_PLATE: 'a12541' | |
#Vault path is different for prod than all other environments | |
VAULT_RESOURCE: ${{ inputs.NAMESPACE == 'a12541-prod' && 'prod' || 'nonprod' }} | |
DB_SUFFIX: ${{ inputs.ENVIRONMENT_NAME == 'dev' && '' || format('-{0}',inputs.ENVIRONMENT_NAME)}} | |
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}} | |
# DEV was created before decision to have multiple environments in single namespace was made. | |
# As such, the DB name is different from later environments - will need to eventually | |
# delete and recreate object. For now, this updates it to match what's expected | |
- name: Perform fix for dev environment | |
if: ${{ inputs.ENVIRONMENT_NAME == 'dev' }} | |
run: | | |
sed -i 's/ name: {{ template "crunchy-postgres.fullname" . }}/ name: crunchy-postgres/' crunchy-postgres/charts/crunchy-postgres/templates/PostgresCluster.yaml | |
cat crunchy-postgres/charts/crunchy-postgres/templates/PostgresCluster.yaml | |
- 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 |