generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 30
33 lines (29 loc) · 1.28 KB
/
remove_review.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Remove Review
on:
workflow_dispatch:
branches:
- '/^review-.*$/'
delete:
branches:
- '*'
jobs:
remove_review:
name: "Remove review"
runs-on: self-hosted
env:
KUBE_CONFIG_BASE64_DATA: ${{ secrets.TEST_CLUSTER_KUBE_CONFIG_BASE64_DATA }}
steps:
- name: Set env for namespace
run: |
REF_NAME=${{ github.event.ref }}
echo "REVIEW_NAMESPACE=$(echo review-${REF_NAME##*/} | sed 's/\_/-/g')" >> $GITHUB_ENV
echo "REVIEW_URL_PREFIX=$(echo ${GITHUB_REF##*/} | sed 's/\_/-/g' | cut -c -30)" >> $GITHUB_ENV
- name: "Drop review namespace"
run: |
kubectl --kubeconfig <(echo $KUBE_CONFIG_BASE64_DATA | base64 --decode) get ns ${{ env.REVIEW_NAMESPACE }} > /dev/null 2>&1 && \
kubectl --kubeconfig <(echo $KUBE_CONFIG_BASE64_DATA | base64 --decode) delete namespace ${{ env.REVIEW_NAMESPACE }} || \
echo "namespace ${{ env.REVIEW_NAMESPACE }} does not exist"
- name: "Drop review databases"
run: |
psql --version
psql -d ${{ secrets.TEST_CLUSTER_DB_CREDENTIALS }} -Atqc "SELECT 'DROP DATABASE ' || quote_ident(datname) || ';' FROM pg_database WHERE datname like '${{ env.REVIEW_URL_PREFIX }}%';" | psql -d ${{ secrets.TEST_CLUSTER_DB_CREDENTIALS }}