post-deploy について
post-deploy は、PR の変更ファイルをチーム設定のルールと照合し、対応する確認や処理を実行するデプロイ後のスキルです。ECR イメージの再ビルド、設定再読み込みの検証、スモークテスト、カスタムコマンドに対応します。
主な機能
- 01変更ファイルをチームルールと照合
- 02ECR イメージの再ビルドとプッシュ
- 03設定再読み込みと実行器の検証
- 04スモークテストやカスタムコマンドの実行
- 05PR へのコメントとレポート作成
活用シーン
- 01デプロイ確認後に対象を絞ったチェックを実施
- 02コード変更後にコンテナイメージを再ビルド
- 03設定更新が読み込まれたか確認
- 04デプロイ後の処理結果を PR にまとめる
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ fellowship-dev/ dogfooded-skills --skill post-deployインストール後、Claude Code で/post-deployを入力して読み込まれたか確認します。
詳細
post-deploy
自律デプロイパイプラインのステージ 3 です。deployed ラベルによってトリガーされます。PR の変更ファイルを読み込み、設定されたパターンと照合して、ECR イメージの再ビルド、設定の再読み込み確認、スモークテスト、カスタムスクリプトなど、対象を絞ったアクションを実行します。
使用するタイミング
- event-rules 経由で
deployedラベルによってトリガーされます(deployment-checker が本番環境へのデプロイを確認した後) - 手動:
/post-deploy PR_NUMBER org/repo
実行方法
/post-deploy 42 fellowship-dev/pylot
ランブック
ステップ 0:重複実行の判定
PR=$1
REPO=$2
# Check if post-deploy already ran (look for a post-deploy comment)
EXISTING=$(gh pr view $PR --repo $REPO --json comments \
--jq '.comments[].body' | grep "Post-deploy actions" || true)
if [ -n "$EXISTING" ]; then
echo "[post-deploy] outcome=\"already complete — post-deploy comment found\" status=success"
exit 0
fi
ステップ 1:PR のコンテキストを読み込む
PR_DATA=$(gh pr view $PR --repo $REPO --json number,title,url,files,mergeCommit,baseRefName)
PR_TITLE=$(echo "$PR_DATA" | python3 -c "import json,sys; print(json.load(sys.stdin)['title'])")
PR_URL=$(echo "$PR_DATA" | python3 -c "import json,sys; print(json.load(sys.stdin)['url'])")
CHANGED_FILES=$(echo "$PR_DATA" | python3 -c "
import json,sys
d = json.load(sys.stdin)
print('\n'.join(f['path'] for f in d['files']))
")
echo "PR: $PR — $PR_TITLE"
echo "Changed files:"
echo "$CHANGED_FILES"
ステップ 2:チームのデプロイ後設定を読み込む
チームの CLAUDE.md から post_deploy: ルールを読み込みます。各ルールはファイルの glob パターンをアクションに対応付けます。
# Example in team CLAUDE.md:
post_deploy:
- match: "Dockerfile*"
action: ecr-rebuild
description: "Rebuild and push ECR image"
- match: "docker-entrypoint.sh"
action: ecr-rebuild
- match: "crew.yml"
action: config-reload-verify
description: "Verify gateway reloaded updated config"
- match: "scripts/*.sh"
action: executor-verify
description: "Spot-check executor behavior"
- match: "event-rules.yml"
action: config-reload-verify
- match: "**"
action: smoke-test
optional: true
description: "Optional smoke test for any PR"
アクションの種類:
| アクション | 説明 |
|---|---|
ecr-rebuild | Docker イメージを再ビルドして ECR にプッシュします |
config-reload-verify | プロセス/ゲートウェイが更新された設定を再読み込みしたことを確認します |
executor-verify | executor またはスクリプトの動作を抜き取り確認します |
smoke-test | チームが定義したスモークテストを実行します |
custom | command フィールドをシェルコマンドとして実行します |
ステップ 3:ファイルをアクションに照合する
# Pseudocode — implement in bash with Python for glob matching
import fnmatch
changed = CHANGED_FILES.splitlines()
triggered_actions = []
for rule in post_deploy_rules:
pattern = rule['match']
matching = [f for f in changed if fnmatch.fnmatch(f, pattern)]
if matching:
triggered_actions.append({
'action': rule['action'],
'description': rule.get('description', rule['action']),
'matched_files': matching,
'optional': rule.get('optional', False)
})
ステップ 4:アクションを実行する
トリガーされた各アクションを実行します。それぞれの結果を記録します。
アクション:ecr-rebuild
# Rebuild and push ECR image
PYLOT_DIR="${PYLOT_DIR:-$HOME/projects/fellowship-dev/pylot}"
ECR_URI="${ECR_URI:-$(grep 'fargate_ecr_uri' $PYLOT_DIR/crew.yml | awk '{print $2}')}"
cd "$PYLOT_DIR"
bash scripts/build-worker-image.sh 2>&1
ECR_EXIT=$?
[ $ECR_EXIT -eq 0 ] && echo "ecr-rebuild: success" || echo "ecr-rebuild: failed exit=$ECR_EXIT"
アクション:config-reload-verify
# Verify the executor/gateway has reloaded the updated config
# For Pylot: check that crew.yml timestamp matches what executor loaded
PYLOT_DIR="${PYLOT_DIR:-$HOME/projects/fellowship-dev/pylot}"
# Check if executor is running and has loaded recent config
CREW_MTIME=$(stat -c %Y "$PYLOT_DIR/crew.yml" 2>/dev/null || stat -f %m "$PYLOT_DIR/crew.yml" 2>/dev/null)
EXECUTOR_PID=$(pgrep -f "executor.sh" || true)
if [ -n "$EXECUTOR_PID" ]; then
echo "config-reload-verify: executor running (pid=$EXECUTOR_PID). crew.yml mtime=$CREW_MTIME."
echo "config-reload-verify: success — executor will pick up config on next poll cycle"
else
echo "config-reload-verify: WARNING — executor not running. Config will load on restart."
fi
アクション:executor-verify
# Spot-check executor behavior — run a quick test
PYLOT_DIR="${PYLOT_DIR:-$HOME/projects/fellowship-dev/pylot}"
# Syntax-check the modified scripts
for script in $MATCHED_SCRIPTS; do
bash -n "$PYLOT_DIR/$script" && echo "executor-verify: $script syntax OK" || echo "executor-verify: $script SYNTAX ERROR"
done
アクション:smoke-test
チームが設定したスモークテストを実行します。デフォルトでは任意です。
# Team-specific smoke test — read from CLAUDE.md smoke_test.command
# Example for Pylot: run a dry-run event dispatch
PYLOT_DIR="${PYLOT_DIR:-$HOME/projects/fellowship-dev/pylot}"
bash "$PYLOT_DIR/event-router.sh" --dry-run 2>&1 | head -20
echo "smoke-test: event-router dry-run complete"
ステップ 5:概要コメントを投稿する
# Build table rows before heredoc (<<'EOF' prevents expansion — pre-build instead)
ACTION_TABLE=""
for action_entry in $TRIGGERED_ACTION_ENTRIES; do
ACTION_NAME=$(echo "$action_entry" | cut -d: -f1)
ACTION_FILES=$(echo "$action_entry" | cut -d: -f2)
ACTION_RESULT=$(echo "$action_entry" | cut -d: -f3)
ACTION_TABLE="${ACTION_TABLE}| ${ACTION_NAME} | ${ACTION_FILES} | ${ACTION_RESULT} |\n"
done
[ -z "$ACTION_TABLE" ] && ACTION_TABLE="_No file-match rules triggered for this PR's changed files._\n"
gh pr comment $PR --repo $REPO --body "$(printf '%s' "## Post-deploy actions
| Action | Matched Files | Result |
|--------|--------------|--------|
$(printf '%b' "$ACTION_TABLE")
**Pipeline complete.** This PR is live and verified.")"
ステップ 6:レポートを作成する
PYLOT_DIR="${PYLOT_DIR:-$HOME/projects/fellowship-dev/pylot}"
REPORT="$PYLOT_DIR/reports/$(date +%Y-%m-%d)-post-deploy-$(echo $REPO | tr '/' '-')-pr${PR}.md"
cat > "$REPORT" <<EOF
# Post-Deploy: $REPO PR #$PR — $PR_TITLE
**Date**: $(date +%Y-%m-%d)
**PR**: [$REPO#$PR]($PR_URL)
## Changed Files
$CHANGED_FILES
## Actions Triggered
$TRIGGERED_ACTIONS_SUMMARY
## Results
$ACTIONS_RESULTS
EOF
デフォルトのファイル照合ルール(Pylot)
| パターン | アクション | 条件 |
|---|---|---|
Dockerfile* | ecr-rebuild | Docker イメージが変更された場合 |
docker-entrypoint.sh | ecr-rebuild | エントリーポイントスクリプトが変更された場合 |
crew.yml | config-reload-verify | Crew 設定が変更された場合 |
event-rules.yml | config-reload-verify | イベントルーティングが変更された場合 |
scripts/*.sh | executor-verify | シェルスクリプトが変更された場合 |
dispatch.sh | executor-verify | ディスパッチロジックが変更された場合 |
executor.sh | executor-verify | Executor ロジックが変更された場合 |
注意事項
- 一致するルールがない場合、アクションは実行されません。 Markdown ファイルのみを変更する PR では何も実行されません。これは正しい動作です。
- 任意のアクション(smoke-test)は実行されますが、概要の判定には影響しません。
- ecr-rebuild が失敗した場合はコメントで通知しますが、
deploy-failedを再適用しません。デプロイ自体は確認済みです。代わりにフォローアップの issue を起票してください。 - チーム設定が基準です。 汎用スキルとチームの CLAUDE.md を組み合わせることで、スキルを変更せずに完全な設定が可能です。
- モノレポの場合: チームに複数のデプロイ先がある場合は、デプロイ先ごとのルールでファイルを照合します。
コメント
Markdown 対応