Skip to content

Remove Review

Remove Review #1477

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 }}