github에서 지원하는 CI/CD 툴이다.
github Acion, Jenkins 등 많이 사용하지만, github Acion의 장점으로 빠르고 간편하게 구축이 가능하다.


AWS 외부에서 실행되는 애플리케이션

-> 해당 키를 알게 된다면 다른 사람들이 사용할 수 있으므로 주의해야한다.

발급 받은 키는 github settings/ security / secreats and variables / actions / repository secrets 에 저장 해둔다.
사용은 yml파일에서 ${{ 저장한 키 이름 }} 으로 사용 가능하다
name : Deploy To S3 And Invalidate Cloudfront
on:
push:
branches:
- main
jobs:
deploy:
runs-on : ubuntu-latest
steps :
- name : Github Repository 파일 불러오기
uses : actions/checkout@v4
- name : Repository 파일 출력
run : ls
- name : 의존성 설치
run : npm i
- name : 빌드하기
run : npm run build
- name : Repository 파일
run : |
ls
cd dist
ls
- name : AWS Resource에 접근 할 수 있게 AWS 인증 설정
uses : aws-actions/configure-aws-credentials@v4
with :
aws-region : ap-northeast-2
aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name : S3기존 파일 전체 삭제
run : aws s3 rm --recursive s3://instagram-web
- name : S3 빌드 파일 업로드
run : aws s3 cp ./dist s3://instagram-web/ --recursive
- name : Cloudfront 캐시 무효화
run : aws cloudfront create-invalidation --distribution-id E1NXWM45UIW090 --paths "/*"