Account for s3 environments mapping to openshift namespace #63
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' }} | ||
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}} | ||
S3_ENVIRONMENT: ${{ fromJson('{ dev: "dev", qa: "dev", dlvr: "test", test: "test", prod: "prod" }')[inputs.ENVIRONMENT_NAME] }} | ||
# 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 | ||
helm upgrade -i crunchy-postgres-${{inputs.ENVIRONMENT_NAME}} ./crunchy-postgres.tar.gz |