Skip to content

[undeploy from OKD] #301

[undeploy from OKD]

[undeploy from OKD] #301

Workflow file for this run

name: '[undeploy from OKD]'
# only trigger on delete non master/staging branch
on:
delete:
branches:
- '!master'
- '!staging'
jobs:
remove-deploy:
runs-on: ubuntu-latest
env:
OC_TEMPLATE_NAME: 'siibra-explorer-branch-deploy-2'
steps:
- name: 'Set env var'
run: |
DEL_REF=${{ github.event.ref }}
echo "Using github.event.ref: $DEL_REF"
BRANCH_NAME=${DEL_REF#refs/heads/}
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "OKD_URL=https://okd-dev.hbp.eu:443" >> $GITHUB_ENV
echo "OKD_SECRET=${{ secrets.OKD_DEV_SECRET }}" >> $GITHUB_ENV
echo "OKD_PROJECT=interactive-atlas-viewer" >> $GITHUB_ENV
echo "Remove deploy from dev cluster..."
- name: 'Login via oc cli'
run: |
oc login $OKD_URL --token=$OKD_SECRET
oc project $OKD_PROJECT
# sanitized branchname == remove _ / and lowercase everything
DEPLOY_ID=$(echo ${BRANCH_NAME//[_\/]/} | awk '{ print tolower($0) }')
echo "DEPLOY_ID=$DEPLOY_ID" >> $GITHUB_ENV
echo "Working branch name: $BRANCH_NAME, sanitized branch name: $DEPLOY_ID"
- name: 'List and delete all labelled resoures'
run: |
oc get all \
-l app=${{ env.OC_TEMPLATE_NAME }}-$DEPLOY_ID
oc delete all \
-l app=${{ env.OC_TEMPLATE_NAME }}-$DEPLOY_ID