Skip to content

ステージング環境へのデプロイワークフローを追加#1497

Merged
TinyKitten merged 1 commit into
devfrom
feature/deploy-ecs-staging-workflow
May 9, 2026
Merged

ステージング環境へのデプロイワークフローを追加#1497
TinyKitten merged 1 commit into
devfrom
feature/deploy-ecs-staging-workflow

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 9, 2026

Copy link
Copy Markdown
Member

概要

ステージング環境向けの ECS デプロイ用 GitHub Actions ワークフローを追加します。既存の本番環境向けワークフロー(deploy_ecs_production_stationapi.yml)に対応するステージング版です。

変更の種類

  • バグ修正
  • 新機能
  • データの修正・追加
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • .github/workflows/deploy_ecs_staging_stationapi.yml を新規追加
    • master への push(.sqlx/** / data/** / scripts/** / stationapi/** / Cargo.lock / Cargo.toml の変更時)または workflow_dispatch でトリガー
    • staging environment を利用し、ECR への docker イメージ push 後に ECS タスク定義を更新してデプロイ
    • 認証・ECR・ECS 関連の設定値はすべて secrets 経由で参照

テスト

  • cargo fmt --all -- --check が通ること
  • cargo clippy -- -D warnings が通ること
  • cargo testSQLX_OFFLINE=true)が通ること

省略: コード本体に変更がないため Rust 系の検証は実施していません。

関連Issue

スクリーンショット(任意)

Summary by CodeRabbit

Chores

  • ステージング環境へのStationAPI自動デプロイメントワークフローを導入しました。このワークフローにより、特定の変更を検出した際にAWS ECSへの自動デプロイメントが実行されます。

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

概要

StationAPI サービスを AWS ECS ステージング環境にデプロイする新しい GitHub Actions ワークフローが追加されました。このワークフローは手動トリガーまたはマスターブランチへのプッシュで起動し、Docker イメージを構築して Amazon ECR にプッシュし、ECS タスク定義を更新して、指定されたサービスをデプロイします。

変更内容

ECS ステージングデプロイメントワークフロー

レイヤー / ファイル 概要
ワークフロートリガーと設定
.github/workflows/deploy_ecs_staging_stationapi.yml
ワークフロー名、手動ディスパッチと条件付きマスターブランチトリガー、AWS/ECR/ECS パラメータを秘密から読み込む環境変数を定義します。
ビルドと ECR プッシュ
.github/workflows/deploy_ecs_staging_stationapi.yml
リポジトリをサブモジュール付きでチェックアウト、AWS 認証情報を設定、ECR にログイン、Docker イメージを構築して github.sha でタグ付けし、ECR リポジトリにプッシュします。
ECS デプロイメント
.github/workflows/deploy_ecs_staging_stationapi.yml
現在の ECS タスク定義をダウンロード、新しくプッシュされたイメージで定義をレンダリング、ECS サービス/クラスタに展開してサービスの安定性を待機します。

推定コードレビュー工数

🎯 2 (シンプル) | ⏱️ 約10分

🐰 ステージング環境へと舞い降りて
Docker イメージは ECR に輝き
ECS のサービスは新しき姿に
自動化の道をすいすいと
デプロイは安定、ウサギも満足♨️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルはステージング環境へのデプロイワークフロー追加という変更内容を明確に述べており、主な変更を正確に要約しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed プルリクエストは要求されたテンプレートの構造に従い、概要・変更の種類・変更内容を正しく記入しており、ほぼ完全です。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/deploy-ecs-staging-workflow

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the feature 要望対応や課題解決 label May 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/deploy_ecs_staging_stationapi.yml (1)

24-29: ⚡ Quick win

並行実行時に古いコミットが後から反映される競合を防いでください

concurrency 未設定のため、連続 push でデプロイが競合し、古い SHA が最後に適用される可能性があります。staging デプロイは直列化しておく方が安全です。

差分案
 jobs:
   deploy:
     name: Deploy StationAPI Staging
     runs-on: self-hosted
     environment: staging
+    concurrency:
+      group: staging-stationapi-${{ github.ref }}
+      cancel-in-progress: true
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy_ecs_staging_stationapi.yml around lines 24 - 29,
deploy ジョブ(job 名 "deploy", environment: staging)で並行実行を制御しておらず、連続 push 時に古い SHA
が後から適用される競合が起きるため、ワークフローかジョブに concurrency 設定を追加して staging デプロイを直列化してください;具体的には
deploy ジョブ("name: Deploy StationAPI Staging"/job id "deploy")に対して一意の group 名(例:
"deploy-stationapi-staging")を指定し、cancel-in-progress: true
を設定して新しい実行が来たら古い進行中の実行をキャンセルするようにしてください。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy_ecs_staging_stationapi.yml:
- Around line 8-14: The workflow currently triggers on changes to source and
config files but misses Docker context; update the on.push.paths in the ECS
staging workflow (.github/workflows/deploy_ecs_staging_stationapi.yml) to
include the Docker build context used by the pipeline (e.g., add "docker/**" or
the exact path where ./docker/api/Dockerfile lives) so pushes that modify
Dockerfile or related docker assets will trigger the deploy; ensure the added
path matches the Docker build reference (./docker/api/Dockerfile) used later in
the job.
- Around line 32-33: The workflow currently pins actions with floating version
tags (e.g., "actions/checkout@v4", "aws-actions/configure-aws-credentials@v4",
"aws-actions/amazon-ecr-login@v2",
"aws-actions/amazon-ecs-render-task-definition@v1",
"aws-actions/amazon-ecs-deploy-task-definition@v2"); replace each of those
`uses:` references with the corresponding commit SHA for that action (e.g.,
"actions/checkout@<commit-sha>") so the deploy workflow is deterministic and
reproducible—update the five occurrences matching those exact strings in the
file to use the proper commit SHAs instead of version tags.
- Around line 24-29: Replace the long-lived AWS access key usage in the Deploy
StationAPI Staging job with the OIDC-based flow by switching the
configure-aws-credentials step to use role-to-assume (the OIDC role) instead of
environment AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, and set the role-to-assume
value to your IAM role; also add a repository-level permissions block that
includes "id-token: write" and "contents: read" so actions/checkout and OIDC
token exchange work (look for the job named "Deploy StationAPI Staging" and the
configure-aws-credentials invocation to update).

---

Nitpick comments:
In @.github/workflows/deploy_ecs_staging_stationapi.yml:
- Around line 24-29: deploy ジョブ(job 名 "deploy", environment:
staging)で並行実行を制御しておらず、連続 push 時に古い SHA が後から適用される競合が起きるため、ワークフローかジョブに concurrency
設定を追加して staging デプロイを直列化してください;具体的には deploy ジョブ("name: Deploy StationAPI
Staging"/job id "deploy")に対して一意の group 名(例:
"deploy-stationapi-staging")を指定し、cancel-in-progress: true
を設定して新しい実行が来たら古い進行中の実行をキャンセルするようにしてください。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e92bcfe4-726a-493c-9bee-4fda9bbac0d6

📥 Commits

Reviewing files that changed from the base of the PR and between f47f670 and ab3bc2f.

📒 Files selected for processing (1)
  • .github/workflows/deploy_ecs_staging_stationapi.yml

Comment thread .github/workflows/deploy_ecs_staging_stationapi.yml
Comment thread .github/workflows/deploy_ecs_staging_stationapi.yml
Comment thread .github/workflows/deploy_ecs_staging_stationapi.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd deploy-dev feature 要望対応や課題解決

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant