Skip to content

Commit a2a1890

Browse files
authored
fix: crunchydb remove user and db when pr is closed. (#2142)
1 parent 85aea12 commit a2a1890

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.github/workflows/pr-close.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,15 @@ jobs:
5252
5353
PATCH_JSON=$(jq -n --argjson users "${UPDATED_USERS}" '{"spec": {"users": $users}}')
5454
oc patch PostgresCluster/postgres-crunchy --type=merge -p "${PATCH_JSON}"
55+
56+
# get primary crunchy pod and remove the role and db
57+
CRUNCHY_PG_PRIMARY_POD_NAME=$(oc get pods -l postgres-operator.crunchydata.com/role=master -o json | jq -r '.items[0].metadata.name')
58+
59+
echo "${CRUNCHY_PG_PRIMARY_POD_NAME}"
60+
61+
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "DROP DATABASE \"app-${{ github.event.number }}\" --cascade"
62+
oc exec "${CRUNCHY_PG_PRIMARY_POD_NAME}" -- psql -c "DROP ROLE \"app-${{ github.event.number }}\" --cascade"
63+
echo 'database and role deleted'
64+
5565
exit 0
5666

0 commit comments

Comments
 (0)