From df1c9cd9e4f742d3a87692f512eb9221d0a57508 Mon Sep 17 00:00:00 2001 From: mamutmk5 <3045922+mamutmk5@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:51:26 +0100 Subject: [PATCH] BC-6013 - move namespace remove to owne file --- .github/workflows/clean_branches.yml | 5 ++- .github/workflows/clean_workflow.yml | 57 +++++++----------------- .github/workflows/clean_workflow_dev.yml | 36 +++++++++++++++ 3 files changed, 55 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/clean_workflow_dev.yml diff --git a/.github/workflows/clean_branches.yml b/.github/workflows/clean_branches.yml index a8a3e4cfe..3b4b1fdc1 100644 --- a/.github/workflows/clean_branches.yml +++ b/.github/workflows/clean_branches.yml @@ -9,5 +9,8 @@ jobs: branch: ${{ github.event.ref }} secrets: token: ${{ secrets.GITHUB_TOKEN }} - DEV_KUBE_CONFIG: ${{ secrets.DEV_KUBE_CONFIG }} + DEV_KUBE_CONFIG_BRB: ${{ secrets.DEV_KUBE_CONFIG_BRB }} + DEV_KUBE_CONFIG_NBC: ${{ secrets.DEV_KUBE_CONFIG_NBC }} + DEV_KUBE_CONFIG_THR: ${{ secrets.DEV_KUBE_CONFIG_THR }} + DEV_KUBE_CONFIG_DBC: ${{ secrets.DEV_KUBE_CONFIG_DBC }} BINGO_REPO_TOKEN: ${{ secrets.BINGO_REPO_TOKEN }} diff --git a/.github/workflows/clean_workflow.yml b/.github/workflows/clean_workflow.yml index 26e629537..5f04f6554 100644 --- a/.github/workflows/clean_workflow.yml +++ b/.github/workflows/clean_workflow.yml @@ -123,20 +123,11 @@ jobs: needs: - examine_branch_existence - create_branch_identifier - steps: - - run: | - mkdir files - echo "${{ secrets.DEV_KUBE_CONFIG_BRB }}" > files/config - - name: delete custom resources and namespaces - run: | - branch_identifier='${{ needs.create_branch_identifier.outputs.id_branch }}' - kubectl --kubeconfig=files/config --namespace brb-$branch_identifier delete --ignore-not-found=true --all=true ScaledObject - kubectl --kubeconfig=files/config --namespace brb-$branch_identifier delete --ignore-not-found=true --all=true TriggerAuthentication - kubectl --kubeconfig=files/config --namespace brb-$branch_identifier delete --ignore-not-found=true --all=true OnePasswordItem - kubectl --kubeconfig=files/config delete --ignore-not-found=true ns brb-$branch_identifier - - name: remove kubeconfig - run: | - rm -rf /config + uses: hpi-schul-cloud/dof_app_deploy/.github/workflows/namespace.yml@BC-6013-split + with: + name: brb-${{ needs.create_branch_identifier.outputs.id_branch }} + secrets: + KUBECONFIG: ${{ secrets.DEV_KUBE_CONFIG_BRB }} delete_namespaces_nbc: runs-on: ubuntu-latest @@ -144,20 +135,11 @@ jobs: needs: - examine_branch_existence - create_branch_identifier - steps: - - run: | - mkdir files - echo "${{ secrets.DEV_KUBE_CONFIG_NBC }}" > files/config - - name: delete custom resources and namespaces - run: | - branch_identifier='${{ needs.create_branch_identifier.outputs.id_branch }}' - kubectl --kubeconfig=files/config --namespace nbc-$branch_identifier delete --ignore-not-found=true --all=true ScaledObject - kubectl --kubeconfig=files/config --namespace nbc-$branch_identifier delete --ignore-not-found=true --all=true TriggerAuthentication - kubectl --kubeconfig=files/config --namespace nbc-$branch_identifier delete --ignore-not-found=true --all=true OnePasswordItem - kubectl --kubeconfig=files/config delete --ignore-not-found=true ns nbc-$branch_identifier - - name: remove kubeconfig - run: | - rm -rf /config + uses: hpi-schul-cloud/dof_app_deploy/.github/workflows/namespace.yml@BC-6013-split + with: + name: nbc-${{ needs.create_branch_identifier.outputs.id_branch }} + secrets: + KUBECONFIG: ${{ secrets.DEV_KUBE_CONFIG_NBC }} delete_namespaces_dbc: runs-on: ubuntu-latest @@ -165,19 +147,10 @@ jobs: needs: - examine_branch_existence - create_branch_identifier - steps: - - run: | - mkdir files - echo "${{ secrets.DEV_KUBE_CONFIG_DBC }}" > files/config - - name: delete custom resources and namespaces - run: | - branch_identifier='${{ needs.create_branch_identifier.outputs.id_branch }}' - kubectl --kubeconfig=files/config --namespace default-$branch_identifier delete --ignore-not-found=true --all=true ScaledObject - kubectl --kubeconfig=files/config --namespace default-$branch_identifier delete --ignore-not-found=true --all=true TriggerAuthentication - kubectl --kubeconfig=files/config --namespace default-$branch_identifier delete --ignore-not-found=true --all=true OnePasswordItem - kubectl --kubeconfig=files/config delete --ignore-not-found=true ns default-$branch_identifier - - name: remove kubeconfig - run: | - rm -rf /config + uses: hpi-schul-cloud/dof_app_deploy/.github/workflows/namespace.yml@BC-6013-split + with: + name: default-${{ needs.create_branch_identifier.outputs.id_branch }} + secrets: + KUBECONFIG: ${{ secrets.DEV_KUBE_CONFIG_DBC }} diff --git a/.github/workflows/clean_workflow_dev.yml b/.github/workflows/clean_workflow_dev.yml new file mode 100644 index 000000000..d6965b080 --- /dev/null +++ b/.github/workflows/clean_workflow_dev.yml @@ -0,0 +1,36 @@ +--- +name: deploy dev + +on: + workflow_call: + inputs: + namespace: + required: true + type: string + secrets: + KUBECONFIG: + required: true + +permissions: + contents: read + +jobs: + delete_namespaces_dbc: + runs-on: ubuntu-latest + if: needs.examine_branch_existence.outputs.are_all_branches_deleted == 'true' + needs: + - examine_branch_existence + - create_branch_identifier + steps: + - run: | + mkdir files + echo "${{ secrets.KUBECONFIG }}" > files/config + - name: delete custom resources and namespaces + run: | + kubectl --kubeconfig=files/config --namespace ${{ inputs.namespace }} delete --ignore-not-found=true --all=true ScaledObject + kubectl --kubeconfig=files/config --namespace ${{ inputs.namespace }} delete --ignore-not-found=true --all=true TriggerAuthentication + kubectl --kubeconfig=files/config --namespace ${{ inputs.namespace }} delete --ignore-not-found=true --all=true OnePasswordItem + kubectl --kubeconfig=files/config delete --ignore-not-found=true ns ${{ inputs.namespace }} + - name: remove kubeconfig + run: | + rm -rf /config