← スキル一覧に戻る

ops-utils
by vm0-ai
ops-utilsは、other分野における実用的なスキルです。複雑な課題への対応力を強化し、業務効率と成果の質を改善します。
⭐ 191🍴 7📅 2026年1月23日
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
スコア
総合スコア
70/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
✓人気
GitHub Stars 100以上
+5
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です


