Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
02b5c2e
chore(ci): test crunchy deployer action
DerekRoberts Apr 24, 2025
b11d110
Trigger build and deploy
DerekRoberts Apr 24, 2025
7c88a8a
chore(ci): test crunchy deployer action
DerekRoberts Apr 24, 2025
6ca8a54
Update workflow branch
DerekRoberts Apr 24, 2025
eaf1da3
Remove crunchy files in this repo
DerekRoberts Apr 24, 2025
3d57fca
Disable trigger and test
DerekRoberts Apr 24, 2025
9d7901c
Junk change to trigger deploy
DerekRoberts Apr 25, 2025
7bb01f3
Junk change to trigger deploy
DerekRoberts Apr 25, 2025
2704b88
Test deployer-db pre-release
DerekRoberts Apr 25, 2025
554ba0b
Test
DerekRoberts Apr 27, 2025
d595ac2
Test
DerekRoberts Apr 27, 2025
a3cadcc
Test from qs-helpers main branch
DerekRoberts Apr 28, 2025
23843e8
Switch to crunchy action from workflow
DerekRoberts May 2, 2025
0b4add5
chore: adding database alias which stich backend with db in knps
mishraomp May 2, 2025
b9e6c35
fix: type, it is string damnit and not sting
mishraomp May 2, 2025
39e481e
fix: remove hardcoding from secret object
mishraomp May 2, 2025
7bc774b
fix: secret name, oh dang
mishraomp May 2, 2025
421d6aa
chore: add logger which is important
mishraomp May 2, 2025
82a102e
fix: handlle no secret
mishraomp May 2, 2025
94bebc4
more testing
mishraomp May 2, 2025
b9f5ee9
debug
mishraomp May 2, 2025
c1b9c3f
add ref
mishraomp May 2, 2025
84a54df
enable backend and frontend
mishraomp May 2, 2025
c83378c
Test against main
DerekRoberts May 2, 2025
dc0c86b
feat: trying to see if the new way of using crunchy deploy works
mishraomp May 2, 2025
66ed631
fix: cruncy release name
mishraomp May 2, 2025
d4c039e
remove some additions
mishraomp May 2, 2025
e5826e8
Try passing in values.yml
DerekRoberts May 4, 2025
49cee69
Add crunchy values.yaml
DerekRoberts May 5, 2025
7d3b8aa
Test passed in values.yml
DerekRoberts May 5, 2025
70bc0fc
yaml => yml
DerekRoberts May 6, 2025
565fd48
Test
DerekRoberts May 6, 2025
36dbd55
Test
DerekRoberts May 6, 2025
c730ae3
Temporarily comment out builds
DerekRoberts May 6, 2025
d80390f
Temporarily comment out builds
DerekRoberts May 6, 2025
9d8a1f5
Add full value path
DerekRoberts May 6, 2025
2ee0130
Change values path
DerekRoberts May 6, 2025
912ab6e
Comment out tests
DerekRoberts May 6, 2025
3fe5231
feat: switch to actions repo
mishraomp May 7, 2025
267e7fa
change to trigger deploy
mishraomp May 8, 2025
7339780
add missing postgres and postgis version
mishraomp May 8, 2025
210e120
Test
DerekRoberts May 9, 2025
12fae2d
fix branch to test pr close
mishraomp May 9, 2025
1231039
Test action on pr-close too
DerekRoberts May 9, 2025
1d8bc95
Force action cleanup
DerekRoberts May 9, 2025
178c204
Test with main branch for action
DerekRoberts May 9, 2025
08709cd
remove force cleanup
mishraomp May 9, 2025
2e5fffa
commit to test all the workflows
mishraomp May 9, 2025
444cdc2
uncomment workflows
mishraomp May 9, 2025
85fbedf
Switch to crunchy v1
DerekRoberts May 9, 2025
e92d264
Use crunchy outputs
DerekRoberts May 9, 2025
e41b17e
Cleanup
DerekRoberts May 9, 2025
48450e1
Debug param (idea via Copilot)
DerekRoberts May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions .github/workflows/.deployer-db.yml

This file was deleted.

40 changes: 25 additions & 15 deletions .github/workflows/.deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ on:
db_user:
description: The database user
required: false
default: 'app'
type: string
debug:
description: Debug mode
default: false
required: false
type: boolean

### Usually a bad idea / not recommended
timeout-minutes:
Expand Down Expand Up @@ -74,26 +80,23 @@ on:
permissions: {}

jobs:
deployer-db:
name: Database
uses: ./.github/workflows/.deployer-db.yml
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
environment: ${{ inputs.environment }}
triggers: ${{ inputs.triggers }}

deploy:
name: Stack
needs: deployer-db
environment: ${{ inputs.environment }}
runs-on: ubuntu-24.04
outputs:
tag: ${{ inputs.tag || steps.pr.outputs.pr }}
triggered: ${{ steps.deploy.outputs.triggered }}
steps:
- uses: actions/checkout@v4
- uses: bcgov/action-crunchy@v1.0.0
name: Deploy Crunchy
id: deploy_crunchy
with:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
environment: ${{ inputs.environment }}
values_file: charts/crunchy/values.yml
triggers: ${{ inputs.triggers }}

# Variables
- if: inputs.tag == ''
Expand Down Expand Up @@ -140,6 +143,11 @@ jobs:
helm uninstall ${{ steps.vars.outputs.release }}
fi

- uses: actions/checkout@v4
- name: Debug Values File
if: inputs.debug == 'true'
run: ls -l charts/crunchy/values.yml

- name: Helm Deploy
id: deploy
uses: bcgov/action-oc-runner@8e5c7737c90e5854c8378555aa933a8eb119ad83 # v1.2.0
Expand All @@ -148,6 +156,7 @@ jobs:
oc_token: ${{ secrets.oc_token }}
oc_server: ${{ vars.oc_server }}
triggers: ${{ inputs.triggers }}
ref: ${{ github.ref }}
commands: |
# Deploy

Expand All @@ -157,12 +166,13 @@ jobs:
# Helm package
sed -i 's/^name:.*/name: ${{ github.event.repository.name }}/' Chart.yaml
helm package -u . --app-version="tag-${{ steps.vars.outputs.tag }}_run-${{ github.run_number }}" --version=${{ steps.pr.outputs.pr || steps.vars.outputs.version }}

# print the values.yaml file to see the values being used
# Helm upgrade/rollout
helm upgrade \
--set-string global.repository=${{ github.repository }} \
--set-string global.tag=${{ steps.vars.outputs.tag }} \
--set-string global.config.databaseUser=${{ inputs.db_user }} \
--set-string global.tag="${{ steps.vars.outputs.tag }}" \
--set-string global.config.databaseUser="${{ inputs.db_user }}" \
--set-string global.databaseAlias="${{ steps.deploy_crunchy.outputs.release }}-crunchy" \
${{ inputs.params }} \
--install --wait ${{ inputs.atomic && '--atomic' || '' }} ${{ steps.vars.outputs.release }} \
--timeout ${{ inputs.timeout-minutes }}m \
Expand Down
31 changes: 2 additions & 29 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,9 @@ jobs:
name: Remove DB User from Crunchy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Remove PR user and database from crunchy
continue-on-error: true
uses: bcgov/action-oc-runner@8e5c7737c90e5854c8378555aa933a8eb119ad83 # v1.2.0
- uses: bcgov/action-crunchy@v1.0.0
name: Remove PR Specific User
with:
oc_namespace: ${{ secrets.oc_namespace }}
oc_token: ${{ secrets.oc_token }}
oc_server: ${{ vars.oc_server }}
commands: |
# check if postgres-crunchy exists or else exit
oc get PostgresCluster/postgres-crunchy || exit 0

# Remove the user from the crunchy cluster yaml and apply the changes
USER_TO_REMOVE='{"databases":["app-${{ github.event.number }}"],"name":"app-${{ github.event.number }}"}'

echo 'getting current users from crunchy'
CURRENT_USERS=$(oc get PostgresCluster/postgres-crunchy -o json | jq '.spec.users')
echo "${CURRENT_USERS}"

# Remove the user from the list,
UPDATED_USERS=$(echo "${CURRENT_USERS}" | jq --argjson user "${USER_TO_REMOVE}" 'map(select(. != $user))')

PATCH_JSON=$(jq -n --argjson users "${UPDATED_USERS}" '{"spec": {"users": $users}}')
oc patch PostgresCluster/postgres-crunchy --type=merge -p "${PATCH_JSON}"

# get primary crunchy pod and remove the role and db
CRUNCHY_PG_PRIMARY_POD_NAME=$(oc get pods -l postgres-operator.crunchydata.com/role=master -o json | jq -r '.items[0].metadata.name')

echo "${CRUNCHY_PG_PRIMARY_POD_NAME}"
# Terminate all connections to the database before trying terminate and Drop the databse and role right after
oc exec -it "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- bash -c "psql -U postgres -d postgres -c \"SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'app-${{ github.event.number }}' AND pid <> pg_backend_pid();\" && \psql -U postgres -d postgres -c \"DROP DATABASE \\\"app-${{ github.event.number }}\\\";\" && \psql -U postgres -d postgres -c \"DROP ROLE \\\"app-${{ github.event.number }}\\\";\""
echo 'database and role deleted'
8 changes: 4 additions & 4 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
triggers: ('backend/' 'frontend/' 'migrations/' 'charts/')

tests:
name: Tests
if: needs.deploys.outputs.triggered == 'true'
needs: [deploys]
uses: ./.github/workflows/.tests.yml
name: Tests
if: needs.deploys.outputs.triggered == 'true'
needs: [deploys]
uses: ./.github/workflows/.tests.yml

results:
name: PR Results
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"author": "BC Government Forestry Suite of Applications Starter Template",
"author": "NRIDS",
"license": "Apache-2.0",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 9 additions & 3 deletions charts/app/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
{{- $databaseName := printf ""}}
{{- $hostWithoutPort := printf ""}}
{{- if .Values.crunchy.enabled}}
{{- $secretName := printf "postgres-crunchy-pguser-%s" .Values.global.config.databaseUser }}
{{- $secretName := printf "%s-pguser-%s" .Values.global.databaseAlias .Values.global.config.databaseUser }}
{{- $databaseUser = .Values.global.config.databaseUser}}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $secretName ) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $secretName ) }}
{{- if not $secretObj }}
{{- fail (printf "Secret %s not found in namespace %s" $secretName .Release.Namespace) }}
{{- end }}
{{- $secretData := (get $secretObj "data") }}
{{- if not $secretData }}
{{- fail (printf "Secret %s data not found in namespace %s" $secretName .Release.Namespace) }}
{{- end }}
{{- $databasePassword = get $secretData "password" }}
{{- $databaseName = b64dec (get $secretData "dbname") }}
{{- $host = printf "%s:%s" (b64dec (get $secretData "host")) (b64dec (get $secretData "port")) }}
Expand Down
26 changes: 0 additions & 26 deletions charts/crunchy/Chart.yaml

This file was deleted.

Loading