일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- webcrawling
- data analyze
- tensorflow
- opencv
- AWS
- angular
- 크롤링
- matplotlib
- data
- python
- 자바스크립트
- keras
- 프로젝트
- TypeScript
- Project
- DANAWA
- Crawling
- visualizing
- analyzing
- 다나와
- javascript
- adaptive life cycle
- ECS
- Method
- 애자일
- Agile
- Scrum
- algorithm
- pandas
- instance
- Today
- Total
LiJell's 성장기
Inject the App Version into the environment file during the EC2 CI/CD process 본문
Inject the App Version into the environment file during the EC2 CI/CD process
All_is_LiJell 2024. 11. 12. 18:08In the project, the environment file is currently updated every time right before deploying to the QA or Prod environment, specifically to change the APP_VERSION value. To avoid unnecessary updates to the environment files, I suggested injecting the app version into the environment file during the CI/CD process.
Method
The backend deployment consists of two sections: GitHub Workflows and AWS Code Series. When code is merged into the GitHub repository, GitHub Workflows are triggered. During the GitHub Action, I will inject the APP_VERSION from the Jira release version into deploy.sh, which is used in the Code Series. The first code block is part of deploy.sh, and the aws s3 sync command will be replaced as shown in the second code block. Then, ENV_FILE and APP_VERSION will be replaced in the GitHub Action just like second code block so that the APP_VERSION is applied during the CI/CD process.
1.
#!/bin/bash
# get environment file from s3
aws s3 sync
ENV_FILE=
APP_VERSION=
sed -i "/^APP_VERSION=/ s|.*|${APP_VERSION}|" /home/ubuntu/.project/${ENV_FILE}
...
2.
- name: Modify deploy script to get and refine env file
run: |
# Define the bucket
bucket="${{ needs.init.outputs.env_bucket }}"
env_script="aws s3 sync s3://${bucket}/latest/ /home/ubuntu/.project/"
sed -i "/^aws s3 sync/ s|.*|${env_script}|" ./codedeploy/deploy.sh
# app version
app_version="${{ inputs.release_version }}"
sed -i "/^APP_VERSION=/ s|.*|APP_VERSION=${app_version}|" ./codedeploy/deploy.sh
# env file name
if [ "${{ inputs.target_branch }}" == "production" ]; then
env_file="production.env"
else
env_file="qa.env"
fi
sed -i "/^ENV_FILE=/ s|.*|ENV_FILE=${env_file}|" ./codedeploy/deploy.sh
'Cloud' 카테고리의 다른 글
S3 Lifecycle expiry date issue (2) | 2024.10.02 |
---|---|
AWS Auto Scaling Group Warmpool (0) | 2024.09.05 |
AWS ECS Managed Termination Protection 옵션 사용시 주의할 점 (0) | 2024.03.13 |
Amazon ECS managed instance draining (0) | 2024.01.31 |
Efficient Multi-Architecture and Multi-Region Container Deployment with Amazon ECS and EC2 Spot Instances (2) | 2024.01.22 |