name: Delete staging infra (REUSABLE) on: workflow_call: inputs: TYPE: required: true type: string secrets: CICD_SECRETS: required: true SECRET_KEY: required: true jobs: delete: if: ${{ always() }} runs-on: ubuntu-latest timeout-minutes: 15 steps: # Prepare - name: Checkout source code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install terraform uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 with: name: tf-${{ inputs.TYPE }} path: /tmp - run: | echo "$SECRET_KEY" > /tmp/.secret_key openssl enc -d -in /tmp/terraform.tar.enc -aes-256-cbc -pbkdf2 -iter 100000 -md sha256 -pass file:/tmp/.secret_key -out /tmp/terraform.tar rm -f /tmp/.secret_key tar xf /tmp/terraform.tar -C / && mkdir ~/.ssh && touch ~/.ssh/id_rsa.pub env: SECRET_KEY: ${{ secrets.SECRET_KEY }} - uses: azure/setup-kubectl@901a10e89ea615cf61f57ac05cecdf23e7de06d8 # v3.2 if: inputs.TYPE == 'k8s' with: version: "v1.28.2" # Remove infra - run: kubectl delete daemonsets,replicasets,services,deployments,pods,rc,ingress,statefulsets --all --all-namespaces --timeout=60s ; kubectl delete pvc --all --timeout=60s ; kubectl delete pv --all --timeout=60s if: inputs.TYPE == 'k8s' continue-on-error: true env: KUBECONFIG: /tmp/k8s/kubeconfig - run: ./tests/rm.sh ${{ inputs.TYPE }} env: CICD_SECRETS: ${{ secrets.CICD_SECRETS }}