Skip to content

delete argocd echo app #19

delete argocd echo app

delete argocd echo app #19

name: delete argocd echo app
on:
workflow_dispatch:
inputs:
repo_name:
description: 'Echo App Repo to delete'
type: string
default: 'echo-app'
cluster-name:
description: 'Name of GKE cluster to delete echo app from'
default: "k8s-demo-cluster"
gcp-region:
type: choice
description: 'GCP region of cluster'
default: "us-east5"
options:
- us-east5
- us-central1
- us-east4
gcp-zone:
type: choice
description: 'GCP zone of cluster'
default: "b"
options:
- a
- b
- c
env:
REPO_NAME: ${{ github.event.inputs.repo_name || 'echo-app' }}
CLUSTER_NAME: ${{ github.event.inputs.cluster-name || 'k8s-demo-cluster' }}
GCP_REGION: ${{ github.event.inputs.gcp-region || 'us-east5' }}
GCP_ZONE: ${{ github.event.inputs.gcp-region || 'us-east5' }}-${{ github.event.inputs.gcp-zone || 'a' }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT }}
GCP_DNS_ZONE: k8s-kurt-madel
jobs:
delete-argocd-echo-app:
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
steps:
- name: checkout
uses: actions/checkout@v3
- name: Generate km-demos GitHub App token
id: generate_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.KM_DEMOS_GITHUB_APP_ID }}
private_key: ${{ secrets.KM_DEMOS_GITHUB_APP_KEY }}
- name: github-cleanup
shell: bash
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/km-demos/$REPO_NAME
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.KM_MANAGE_PACKAGES_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/km-demos/packages/container/$REPO_NAME
- id: 'gcp-auth'
name: 'Authenticate to Google Cloud'
uses: google-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.WIF_POOL }}
service_account: ${{ secrets.SA_EMAIL }}
- id: get-credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.GCP_ZONE }}
- id: gcp-cleanup
run: |
kubectl delete application --ignore-not-found=true -n argocd $REPO_NAME
kubectl delete applicationset --ignore-not-found=true -n argocd $REPO_NAME
kubectl delete ns --ignore-not-found=true $REPO_NAME
gcloud dns record-sets delete $REPO_NAME.k8s.kurtmadel.com. --type=A --zone=$GCP_DNS_ZONE --project=$GCP_PROJECT_ID