workflow について
GitHub CLI で GitHub Actions の CI/CD 実行を管理するスキルです。開発者がワークフローの確認、調査、再実行、監視を行い、成果物の取得や手動実行にも対応します。
主な機能
- 01ブランチ、ワークフロー、状態で実行を一覧
- 02実行の詳細と失敗ログを確認
- 03ワークフローまたは失敗ジョブを再実行
- 04実行を監視して終了状態を確認
- 05実行成果物をダウンロード
- 06ワークフローの有効化や手動実行
活用シーン
- 01マージ前に CI の状態を確認
- 02失敗した実行のログを調査
- 03修正後に失敗ジョブを再試行
- 04デプロイ実行を監視
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ johnlindquist/ claude --skill workflowインストール後、Claude Code で/workflowを入力して読み込まれたか確認します。
詳細
GitHub Actions ワークフローマネージャー
GitHub CLI を使用して、CI/CD ワークフローを監視、管理します。
前提条件
GitHub CLI をインストールします:
brew install gh
# or
curl -sS https://webi.sh/gh | sh
認証します:
gh auth login
CLI リファレンス
ステータスをすばやく確認
# Current branch CI status
gh run list --branch $(git branch --show-current) --limit 5
# All recent runs
gh run list --limit 10
# Filter by workflow
gh run list --workflow "CI" --limit 5
特定の実行を表示
# Get run details
gh run view <run-id>
# View with logs
gh run view <run-id> --log
# Failed jobs only
gh run view <run-id> --log-failed
# Exit codes for CI scripts
gh run view <run-id> --exit-status
フィルターを指定して実行を一覧表示
# By branch
gh run list --branch main --limit 10
# By workflow name
gh run list --workflow "Build and Test" --limit 10
# By status
gh run list --status failure --limit 10
gh run list --status success --limit 10
gh run list --status in_progress --limit 10
# Combined filters
gh run list --branch main --workflow "CI" --status failure --limit 5
ワークフローを再実行
# Rerun entire workflow
gh run rerun <run-id>
# Rerun only failed jobs
gh run rerun <run-id> --failed
# Rerun specific job
gh run rerun <run-id> --job <job-id>
実行中のワークフローを監視
# Watch a run in progress
gh run watch <run-id>
# Watch and exit with run's exit code
gh run watch <run-id> --exit-status
アーティファクトをダウンロード
# List artifacts from a run
gh run view <run-id> --json artifacts
# Download all artifacts
gh run download <run-id>
# Download specific artifact
gh run download <run-id> --name "artifact-name"
# Download to specific directory
gh run download <run-id> --dir ./artifacts
実行をキャンセル
gh run cancel <run-id>
ワークフローファイルを表示
# List workflow files
gh workflow list
# View specific workflow
gh workflow view "CI"
# Enable/disable workflow
gh workflow enable "CI"
gh workflow disable "CI"
ワークフローを手動で実行
# Trigger workflow_dispatch
gh workflow run "CI"
# With inputs
gh workflow run "Deploy" -f environment=staging -f version=1.2.3
# On specific branch
gh workflow run "CI" --ref feature-branch
出力形式
# JSON output for parsing
gh run list --json status,conclusion,name,headBranch,url
# Specific fields
gh run view <run-id> --json jobs,status,conclusion
ワークフローのパターン
CI をすばやく確認
# Is my branch passing?
gh run list --branch $(git branch --show-current) --limit 1 --json status,conclusion
失敗した CI のデバッグ
# 1. Find the failing run
gh run list --branch main --status failure --limit 1
# 2. View failed logs
gh run view <run-id> --log-failed
# 3. After fixing, rerun
gh run rerun <run-id> --failed
デプロイを監視
# Watch deployment in progress
gh run watch <run-id>
# Get notified when done (macOS)
gh run watch <run-id> && osascript -e 'display notification "Deployment complete"'
不安定なテストを再試行
# Rerun just the failed jobs
gh run rerun <run-id> --failed
マージ前の確認
# Ensure all checks pass before merging
gh run list --branch $(git branch --show-current) --json conclusion --jq '.[0].conclusion'
一般的なステータス
| ステータス | 意味 |
|---|---|
queued | 開始待ち |
in_progress | 実行中 |
completed | 完了 |
| 結果 | 意味 |
|---|---|
success | すべてのジョブが成功 |
failure | 1 つ以上のジョブが失敗 |
cancelled | 実行がキャンセルされました |
skipped | 実行がスキップされました |
timed_out | 実行が制限時間を超過しました |
ベストプラクティス
- マージ前にステータスを確認 - CI が成功していることを確認します
--log-failedを使用 - 関連する失敗ログのみを確認します- まず
--failedで再実行 - 全体を再実行するより高速です - 長時間の実行を監視 - 手動でポーリングしないでください
- アーティファクトをダウンロード - テストレポートやカバレッジなどに使用します
- JSON 出力を使用 - スクリプトでの処理や解析に使用します
コメント
Markdown 対応