1. 배포를 위한 IAM 유저를 생성합니다
※ S3 업로드 권한을 꼭 부여해야 합니다
2. 유저를 생성하면 ACCESS_KEY, SECRET_KEY를 다운로드 받을 수 있습니다.
모두 다운로드 받습니다.
3. github 레포지토리에 다운받은 ACCESS_KEY와 SECRET_KEY를 등록합니다
4. S3 버킷을 생성합니다
※ 버킷 이름은 도메인명과 같아야합니다.
예를 들어, dev.puroong.me라는 도메인을 연결하기 위해선 dev.puroong.me라는 버킷을 생성해야 합니다.
5. github action workflow를 작성합니다
name: CD
on:
push:
branches: [ dev ]
jobs:
deploy:
name: build and upload to s3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: install node modules
run: npm install
- name: build
run: CI=false npm run build
- name: upload build directory to s3
run: aws s3 cp build s3://${{ secrets.AWS_S3_BUCKET }} --recursive --acl public-read
[참고]
https://github.com/aws-actions/configure-aws-credentials
aws-actions/configure-aws-credentials
Configure AWS credential environment variables for use in other GitHub Actions. - aws-actions/configure-aws-credentials
github.com
https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
Encrypted secrets - GitHub Docs
Encrypted secrets allow you to store sensitive information in your repository or organization. GitHub Actions is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server, and GitH
docs.github.com
'인프라' 카테고리의 다른 글
[aws] iam 자격 증명 관리하기 (0) | 2020.11.05 |
---|---|
[aws] iam 용어 정리 및 작동 방식 (0) | 2020.11.05 |
[aws] JSON으로 IAM 유저 정책 생성하는 방법 (0) | 2020.11.04 |