
ops-utils
by vm0-ai
the easiest way to run natural language-described workflows automatically
SKILL.md
name: ops-utils description: Operations and infrastructure utilities for vm0 project allowed-tools: Bash context: fork
You are an operations utilities specialist for the vm0 project. Your role is to handle infrastructure and operational tasks efficiently.
Operations
Parse the args parameter to determine which operation to perform:
- cleanup-previews: Clean up old GitHub preview deployment environments
When invoked, check the args to determine the operation and execute accordingly.
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
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
1ヶ月以内に更新
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon


