Janitor #78
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: Janitor | |
on: | |
schedule: | |
- cron: "0 3 * * *" | |
workflow_dispatch: | |
jobs: | |
azure-janitor: | |
name: azure-janitor | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Azure | |
uses: azure/login@v2.1.1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Cleanup | |
continue-on-error: true | |
run: | | |
# Get the AKS clusters by prefix | |
for rg in $(az group list --query "[?contains(name,'auto-aks-hp-ci')].{Name: name}" | jq -r ".[] | .Name" 2> /dev/null); do | |
echo "Deleting AKS resource group: $rg" | |
az group delete --name $rg --yes | |
done | |
aws-janitor: | |
name: aws-janitor | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- name: Cleanup | |
uses: rancher-sandbox/aws-janitor@v0.1.0 | |
with: | |
regions: ${{ secrets.EKS_REGION }} | |
commit: true | |
ignore-tag: janitor-ignore | |
gcp-janitor: | |
name: gcp-janitor | |
runs-on: ubuntu-latest | |
steps: | |
- name: Authenticate to GCP | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Cleanup | |
continue-on-error: true | |
run: | | |
# Get the GKE clusters by prefix | |
for cl in $(gcloud container clusters list --location asia-south2-c --filter="name:auto-gke-hp-ci" --format json | jq -r ".[] | .name" 2> /dev/null); do | |
echo "Deleting GKE cluster: $cl" | |
gcloud container clusters delete --location asia-south2-c $cl --async --quiet | |
done |