Init
Some checks failed
Build & Deploy Game / build-and-deploy (push) Failing after 6s
Some checks failed
Build & Deploy Game / build-and-deploy (push) Failing after 6s
This commit is contained in:
37
.github/workflows/cleanup.yaml
vendored
Normal file
37
.github/workflows/cleanup.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: Cleanup Environment
|
||||
on: [delete]
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.ref_type == 'branch'
|
||||
|
||||
steps:
|
||||
- name: Prepare Variables
|
||||
run: |
|
||||
REPO_LOWER=$(echo "${{ gitea.repository }}" | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')
|
||||
BRANCH_NAME=${{ github.event.ref }}
|
||||
BRANCH_LOWER=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g')
|
||||
TARGET_NS="${REPO_LOWER}-${BRANCH_LOWER}"
|
||||
echo "TARGET_NS=$TARGET_NS" >> $GITHUB_ENV
|
||||
|
||||
- name: Protect Main
|
||||
if: env.TARGET_NS == 'escape-teacher-main' || env.TARGET_NS == 'escape-teacher-master'
|
||||
run: |
|
||||
echo "❌ Main darf nicht gelöscht werden!"
|
||||
exit 1
|
||||
|
||||
- name: Setup Kubectl
|
||||
run: |
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
chmod +x kubectl
|
||||
mv kubectl /usr/local/bin/
|
||||
mkdir -p $HOME/.kube
|
||||
echo "${{ secrets.KUBE_CONFIG }}" > $HOME/.kube/config
|
||||
chmod 600 $HOME/.kube/config
|
||||
sed -i 's|server: https://.*:6443|server: https://kubernetes.default.svc:443|g' $HOME/.kube/config
|
||||
|
||||
- name: Delete Namespace
|
||||
run: |
|
||||
echo "🗑️ Lösche Namespace: ${{ env.TARGET_NS }}"
|
||||
kubectl delete namespace ${{ env.TARGET_NS }} --ignore-not-found --wait=false
|
||||
Reference in New Issue
Block a user