Delete apps and namespace after deleting branch #274
This file contains 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 apps and namespace after deleting branch | |
# trigger on branch deletion to bind the namespaces lifecycle to the branch lifecycle | |
on: | |
delete: | |
branches: | |
- 'feature-**' | |
jobs: | |
delete: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v1 | |
- name: Authenticate and set context | |
uses: redhat-actions/oc-login@v1 | |
with: | |
# URL to your OpenShift cluster. | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_FIWARE }} | |
# Authentication Token. Can use username and password instead. | |
openshift_token: ${{ secrets.OPENSHIFT_TOKEN_FIWARE }} | |
# Disables SSL cert checking. Use this if you don't have the certificate authority data. | |
insecure_skip_tls_verify: true | |
- name: Delete applications | |
run: | | |
# remove all apps deployed for the namespace corresponding to the branch | |
oc delete application -l destination-namespace=${{ github.event.ref }} -n argocd | |
# delete the namespace associated to the trigger event's branch | |
- name: Delete namespace | |
run: | | |
oc delete project ${{ github.event.ref }} |