Delete Deployment #374
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Delete Deployment | |
| on: | |
| delete: | |
| jobs: | |
| delete: | |
| if: github.event.ref_type == 'branch' && startsWith(github.event.ref, 'refs/heads/feature/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set DEPLOY_ID which will delete a custom deploy from 'dev' environment | |
| run: | | |
| echo "BRANCH = ${{ github.event.ref }}" | |
| export BRANCH="${{ github.event.ref }}" | |
| echo "::set-output name=DEPLOY_ID::${BRANCH//\//-}" | |
| id: set-deploy-id | |
| - name: Get deploy ID | |
| run: echo "The DEPLOY_ID is ${{ steps.set-deploy-id.outputs.DEPLOY_ID }}" | |
| - uses: actions/checkout@v2 | |
| - name: Install oc | |
| uses: redhat-actions/oc-installer@v1 | |
| with: | |
| version: '4.6' | |
| - name: Authenticate and set context | |
| uses: redhat-actions/oc-login@v1 | |
| with: | |
| openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} | |
| openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | |
| # Disables SSL cert checking. Use this if you don't have the certificate authority data. | |
| insecure_skip_tls_verify: true | |
| namespace: ${{ env.OPENSHIFT_NAMESPACE }} | |
| - name: 'Get Helm' | |
| run: | | |
| curl -L -O https://get.helm.sh/helm-v3.4.2-linux-amd64.tar.gz | |
| tar -xf helm-v3.4.2-linux-amd64.tar.gz | |
| - name: 'Delete DB (Postgres k8s resources)' | |
| run: | | |
| DEPLOY_ID="${{ steps.set-deploy-id.outputs.DEPLOY_ID }}" | |
| DB_NAME="proto-asp-${DEPLOY_ID}-db" | |
| oc delete deployment "${DB_NAME}" --ignore-not-found=true | |
| oc delete service "${DB_NAME}" --ignore-not-found=true | |
| oc delete pvc "${DB_NAME}-data" --ignore-not-found=true | |
| oc delete configmap "${DB_NAME}-init" "${DB_NAME}-keystone-schema" --ignore-not-found=true | |
| oc delete job "${DB_NAME}-keystone-init" --ignore-not-found=true | |
| - name: 'Delete ALL (Helm releases)' | |
| run: | | |
| export PATH=$PATH:`pwd`/linux-amd64 | |
| # for old MongoDB Helm releases | |
| helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-db --ignore-not-found | |
| helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }} | |
| helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-routes | |
| helm delete proto-asp-${{ steps.set-deploy-id.outputs.DEPLOY_ID }}-feeder |