

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# GitHub Actions を使用した Elastic Beanstalk へのデプロイ
<a name="deploying-github-actions"></a>

[GitHub Actions](https://docs.github.com/en/actions) は、コード変更をリポジトリにプッシュするときに、アプリケーションを Elastic Beanstalk に自動的にデプロイできます。[Elastic Beanstalk Deploy](https://github.com/aws-actions/aws-elasticbeanstalk-deploy) アクションは、アプリケーションバージョンの作成、Amazon S3 へのソースバンドルのアップロード、Elastic Beanstalk 環境へのデプロイを処理するシンプルな YAML インターフェイスを提供します。

## ワークフローの例
<a name="deploying-github-actions-example"></a>

次のワークフロー例では、`main`ブランチにプッシュするたびにアプリケーションを Elastic Beanstalk 環境にデプロイします。リポジトリの `.github/workflows/` に `.yml` ファイルを作成します。

**Example Elastic Beanstalk デプロイの GitHub Actions ワークフロー**  

```
name: Deploy to Elastic Beanstalk

on:
  push:
    branches:
      - main

permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::{{123456789012}}:role/{{my-github-actions-role}}
          aws-region: {{us-east-1}}

      - name: Deploy to Elastic Beanstalk
        uses: aws-actions/aws-elasticbeanstalk-deploy@v1.0.0
        with:
          aws-region: {{us-east-1}}
          application-name: {{my-application}}
          environment-name: {{my-application-env}}
```

このワークフローでは、リポジトリをチェックアウトし、[OpenID Connect (OIDC)](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services) を使用して[認証情報の設定 AWS](https://github.com/aws-actions/configure-aws-credentials)アクション AWS を通じて で認証してから、アプリケーションを Elastic Beanstalk にデプロイします。デプロイアクションは、リポジトリのコンテンツをパッケージ化し、ソースバンドルを Amazon S3 にアップロードし、新しいアプリケーションバージョンを作成し、環境を作成または更新します。デフォルトでは、デプロイが完了し、環境が正常な状態に戻るのを待ちます。

その他の設定オプションと詳細な例については、GitHub の[「Elastic Beanstalk Deploy action README](https://github.com/aws-actions/aws-elasticbeanstalk-deploy#readme)」を参照してください。

## その他のリソース
<a name="deploying-github-actions-resources"></a>
+ GitHub での [Elastic Beanstalk デプロイアクション](https://github.com/aws-actions/aws-elasticbeanstalk-deploy) 
+ GitHub [で AWS 認証情報アクションを設定する](https://github.com/aws-actions/configure-aws-credentials) 
+ [Configuring OpenID Connect in Amazon Web Services](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services) (GitHub ドキュメント)