Skip to content

Commit

Permalink
feat: add cdk deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuki-joto committed Nov 24, 2022
1 parent 65f8bd5 commit 027d21c
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ on:
tags:
- 'v*'

env:
AWS_ROLE_ARN: arn:aws:iam::887442827229:role/GithubActions_decidim-cfj-cdk-deploy

jobs:
create-app-env:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
actions: write
contents: read
id-token: write
outputs:
image-tag: ${{ steps.output-app-env.outputs.image-tag }}
eb-environment-name: ${{ steps.output-app-env.outputs.eb-environment-name }}
Expand Down Expand Up @@ -111,15 +118,27 @@ jobs:
- name: Install awsebcli
run: pip install -U awsebcli

- name: Deploy to Elastic Beanstalk
- name: Checkout decidim-cfj cdk
uses: actions/checkout@v3
with:
repository: codeforjapan/decidim-cfj-cdk
path: ./

- name: aws switch role
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ap-northeast-1

- name: cdk deploy
uses: youyo/aws-cdk-github-actions@v2
with:
cdk_subcommand: 'deploy'
cdk_version: '2.50.0'
actions_comment: true
cdk_args: '--context stage=$EB_ENVIRONMENT_NAME --context tag:$IMAGE_TAG --require-approval never'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_DEFAULT_REGION: 'ap-northeast-1'
EB_ENVIRONMENT_NAME: ${{ needs.create-app-env.outputs.eb-environment-name }}
IMAGE_TAG: ${{ needs.create-app-env.outputs.image-tag }}
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
run: |
cd deployments
cp ${EB_ENVIRONMENT_NAME}/*.config .ebextensions/
sed -i -e "s|{RepositoryName}|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" docker-compose.yml
sed -i -e "s|{EBEnvironment}|$EB_ENVIRONMENT_NAME|g" docker-compose.yml
eb deploy ${EB_ENVIRONMENT_NAME} --timeout=20 --process

0 comments on commit 027d21c

Please sign in to comment.