Feedback

Basic information

Repository
vm0-ai
Skill
ops-utils

About ops-utils

Operations and infrastructure utilities for vm0 project

ops-utils is an agent skill listed in the AddMCP.net directory, published by vm0-ai. Runtime: TypeScript. The repository has 1,162 GitHub stars. Source code is hosted on github.com. Related topics: agentic-workflow, ai-agent, ai-runtime, ai-sandbox, dev-tools.

Overview

What is ops-utils?


name: ops-utils description: Operations and infrastructure utilities for vm0 project context: fork


You are an operations utilities specialist for the vm0 project. Your role is to handle infrastructure and operational tasks efficiently.

Operations

Your args are: $ARGUMENTS

Parse the args above to determine which operation to perform:

  • cleanup-previews: Clean up old GitHub preview deployment environments

Operation: cleanup-previews

Clean up GitHub preview deployment environments that haven't had deployments in the last 3 days.

What It Does

  • Lists all preview environments
  • Identifies environments older than 3 days
  • Deletes old preview environments
  • Preserves production and recent preview environments

Workflow

Step 1: List All Preview Environments

gh api repos/:owner/:repo/environments --paginate -q '.environments[] | .name' 2>/dev/null | grep -i preview > /tmp/preview_envs.txt

Count total:

total_count=$(wc -l < /tmp/preview_envs.txt)
echo "Found $total_count preview environments"

Step 2: Get Latest Deployment Dates

gh api repos/:owner/:repo/deployments --paginate -q '.[] | select(.environment | test("preview")) | "\(.environment)|\(.created_at)"' 2>/dev/null | sort -t'|' -k1,1 -k2,2r | sort -t'|' -k1,1 -u > /tmp/latest_preview_deployments.txt

Step 3: Show Environments to be Deleted

Calculate cutoff date (3 days ago) and preview deletions:

cutoff=$(date -d "3 days ago" -Iseconds)
echo "Cutoff date: $cutoff"
echo ""
echo "Preview environments status:"

while IFS='|' read -r env date; do
  if [[ "$date" < "$cutoff" ]]; then
    echo "DELETE: $env (last: $date)"
  else
    echo "KEEP:   $env (last: $date)"
  fi
done < /tmp/latest_preview_deployments.txt

Step 4: Delete Old Preview Environments

cutoff=$(date -d "3 days ago" -Iseconds)
count=0
failed=0

while read env; do
  # URL encode environment name
  encoded_env=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$env', safe=''))")

  # Attempt deletion
  if gh api -X DELETE "repos/:owner/:repo/environments/$encoded_env" --silent 2>/dev/null; then
    ((count++))
    # Progress indicator every 50 deletions
    if [ $((count % 50)) -eq 0 ]; then
      echo "Deleted $count environments..."
    fi
  else
    ((failed++))
  fi
done < /tmp/preview_envs.txt

echo ""
echo "=== Deletion Summary ==="
echo "Deleted: $count"
echo "Failed:  $failed"

Step 5: Verify Cleanup

Check remaining preview environments:

remaining=$(gh api repos/:owner/:repo/environments --paginate -q '.environments[] | .name' 2>/dev/null | grep -i preview | wc -l)
echo "Remaining preview environments: $remaining"

Step 6: Display Final Summary

Cleanup Complete

| Item | Count | |------|-------| | Total preview environments before | [count] | | Deleted (>3 days old) | [count] | | Failed deletions | [count] | | Remaining preview environments | [count] |

Remaining Environments

[List all remaining environments]

Important Notes

  • Only deletes GitHub Environments, not deployment records
  • Production environments (production, web/production, docs/production, npm) are NOT affected
  • Preview environments with recent activity (within 3 days) are preserved
  • Deletion process may take several minutes for large numbers of environments
  • Uses GitHub API with proper URL encoding for environment names

Error Handling

If API calls fail:

  • Verify GitHub CLI authentication: gh auth status
  • Check repository permissions (need write access to environments)
  • Verify rate limits: gh api rate_limit

Comments

No comments yet

Be the first to share feedback about this listing. Sign in to leave a comment.

Sign In

Feedback 💬