어플리케이션 개발 단계부터 배포까지의 단계를 자동화해서 애플리케이션을 효율적이고 빠르게, 더 자주 사용자에게 배포할 수 있도록 만드는 것
(출처: CI/CD(Continuous Integration/Continuous Delivery)란?)
AWS_SECRET_ACCESS_KEY
가 외부에 노출되면 안되기 때문에 Github actions Secrets 기능을 활용하여 환경 변수로 관리해준다.
# .github/workflows/client.yml
name: client # 워크플로의 이름
on: # branches와 일치하는 분기, 즉 reference 브랜치에 푸시가 발생할 때만 워크플로가 실행되도록 필터 설정
push:
branches:
- reference
jobs: # 워크플로우로 실행할 작업 목록
build:
runs-on: ubuntu-20.04 # 작업을 실행할 시스템 유형 정의하기
steps: # 작업에서 실행되는 모든 단계를 그룹화한 것
- name: Checkout source code. # 러너에서 리포지토리를 확인
uses: actions/checkout@v2
- name: Install dependencies # dependencies 설치하기
run: npm install
working-directory: ./my-agora-states-client
- name: Build # 소스코드 빌드하기(이를 통해 Build 폴더 생성됨)
run: npm run build
working-directory: ./my-agora-states-client
- name: SHOW AWS CLI VERSION # AWS 버전 확인하기
env: # Secrets을 활용해서 환경변수로 등록한 AWS Key가 사용됨
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws --version
- name: Sync Bucket # 생성된 build 폴더와 버킷 동기화하기
env: # Secrets을 활용해서 환경변수로 등록한 AWS Key가 사용됨
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 sync \
--region ap-northeast-2 \
build s3://<s3 버킷 이름 넣기> \
--delete
working-directory: ./my-agora-states-client
참고자료
CI/CD(Continuous Integration/Continuous Delivery)란?
CI/CD 5분 개념 정리 (현업에서 쓰는 개발 프로세스)
Github Actions 알아보기 - 워크플로 정보