Skip to content

unused aws instace and vpcs cleanup #30

unused aws instace and vpcs cleanup

unused aws instace and vpcs cleanup #30

Workflow file for this run

name: Daily AWS Cleanup Bot
# on:
# schedule:
# - cron: '0 8 * * *'
on:
pull_request:
types:
- opened
- synchronize
branches:
- awsresourcecleanup
push:
branches:
- awsresourcecleanup
jobs:
cleanup:
runs-on: linux-amd64-cpu4
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
- name: Identify resources running longer than 4 hours
id: identify-resources
run: |
# Find vpcs with names ci*
vpcs=$(aws ec2 describe-vpcs \
--filters "Name=tag:Name,Values=ci*" \
--query "Vpcs[].VpcId" \
--output text | tr -d '\r' | tr '\n' ' ')
echo "Found VPCs: $vpcs"
echo "vpcs=$vpcs" >> $GITHUB_ENV
- name: Clean up VPCs
if: env.vpcs != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for vpc in $vpcs; do
GITHUB_REPOSITORY1=gpu-driver-container
RUN_ID1="12338981626"
JOB_NAME=e2e-tests-nvidiadriver
# https://api.github.com/repos/NVIDIA/gpu-driver-container/actions/runs/12338981626
# https://api.github.com/repos/NVIDIA/${GITHUB_REPOSITORY1}/actions/runs/${RUN_ID1}
response=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/NVIDIA/${GITHUB_REPOSITORY1}/actions/runs/${RUN_ID1}/jobs")
echo "Response: $response"
echo "SHIVA $response"
status=$(echo "$response" | jq -r ".jobs[] | select(.name == \"$JOB_NAME\") | .status")
conclusion=$(echo "$response" | jq -r ".jobs[] | select(.name == \"$JOB_NAME\") | .conclusion")
echo "status=$status"
echo "conclusion=$conclusion"
scripts/awsvpcscleanup.sh $vpc
done
- name: Post cleanup
run: |
echo "Cleanup completed."