4. CD 구축(github actions)
깃헙 레포 settings > Secrets and variables > actions 에 환경변수 등록 해야함
# .github/workflows/deploy.yml
name: Deploy to AWS Elastic Beanstalk
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Zip Artifacts for Deployment
run: zip -r deploy.zip .
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}
run: |
aws configure set region $AWS_REGION
aws s3 cp deploy.zip s3://s3버킷명/deploy.zip
- name: Deploy to Elastic Beanstalk
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_REGION: ${{secrets.AWS_REGION}}
run: |
aws elasticbeanstalk create-application-version \
--application-name "eb어플리케이션명" \
--version-label $GITHUB_SHA \
--source-bundle S3Bucket="s3버킷명",S3Key="deploy.zip"
aws elasticbeanstalk update-environment \
--application-name "eb어플리케이션명" \
--environment-name "eb환경명" \
--version-label $GITHUB_SHA
'TIL' 카테고리의 다른 글
[241219 TIL] Framer-motion 기초 (0) | 2024.12.19 |
---|---|
[241209 TIL] AWS - RDS, EB 에 nest 배포(3) (0) | 2024.12.09 |
[241208 TIL] AWS - RDS, EB 에 nest 배포(1) (0) | 2024.12.09 |
[241203 TIL] gql apolloClient 기본 사용법 (0) | 2024.12.03 |
[241115 TIL] as const (0) | 2024.11.15 |