-
[CI/CD] Vue.js GitHub Actions 적용기 #3 (sandbox, qa)CICD 2022. 8. 16. 14:55
https://honggom.tistory.com/199
[CI/CD] GitHub Actions 적용기 #1 (Front-prod)
회사에서 기존에 모든 프로젝트를 GitLab을 통해 관리하고 있었는데 여러 이유로 GitHub으로 이전하기로 결정했다. 그래서 GitLab에 구축 해놓은 CI/CD를 GitHub에 맞게 다시 구축해야 됐고 그 일을 나도
honggom.tistory.com
https://honggom.tistory.com/202
[CI/CD] GitHub Actions 적용기 #2 (test)
https://honggom.tistory.com/199 [CI/CD] GitHub Actions 적용기 #1 (Front-prod) 회사에서 기존에 모든 프로젝트를 GitLab을 통해 관리하고 있었는데 여러 이유로 GitHub으로 이전하기로 결정했다. 그래서 GitLa..
honggom.tistory.com
이번 글에서는 prod와 test에 이어 Front의 마지막으로 sandbox, qa 워크플로우를 다룬다.
sandbox, qa의 워크플로우
- sandbox, qa 브랜치가 push되면 동작
- repository checkout
- node setup 및 cache
- ci
- build
- upload to s3
- cloudfront invalidate
- send slack message
간단히 훑어보면 lint하는 과정이 빠져있는데 그 이유는 아래와 같다.
- sandbox와 qa의 push가 잦아서 워크플로우 시간을 단축하기 위해.
- test에 lint하는 과정이 있어서 중복되기 때문에.
1. sandbox, qa 브랜치가 push되면 동작
name: deploy-sandbox-qa on: push: branches: [ sandbox, qa ]
sandbox와 qa브랜치에 push되면 이 워크플로우가 동작한다.
2. repository checkout
jobs: deploy-sandbox-qa: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@main
GitHub Actions에서 제공하는 actions/checkout을 사용하면 해당 repository로 checkout한다.
3. node setup 및 cache
- name: setup node uses: actions/setup-node@main with: node-version: 16 cache: 'npm'
node setup과 의존성 cache도 그냥 플러그인을 가져다가 쓰면 되고 환경에 맞게 버전과 같은 변수만 설정해주면 된다. 이렇게 하면 해당 워크플로우 환경에 명시된 버전으로 node가 설치되고 cache도 알아서 해준다.
4, 5 : ci, build
- name: ci run: npm ci - name: build run: npm run build -- --mode ${{ github.ref_name }}
npm 의존성을 설치하고 소스를 빌드한다. 여기서 ${{ github.ref_name }}는 push된 브랜치명(ex: sandbox)을 나타낸다.
6. upload to s3
앞에 글에서도 다뤘지만 build한 소스를 AWS S3에 업로드하는 과정이다.
- name: upload to s3 run: aws s3 sync --region $AWS_REGION dist $AWS_S3_URL/${{ github.ref_name }}/
(설명은 앞 글에서 했기에 생략..)
7. cloudfront invalidate
- name: invalidate cloudfront run: | if [ ${{ github.ref_name == 'sandbox' }} ]; then DISTRIBUTION=... fi if [ ${{ github.ref_name == 'qa' }} ]; then DISTRIBUTION=... fi aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION} --paths "/index.html"
(설명은 앞 글에서 했기에 생략..)
8. send slack message
- name: send slack message uses: 8398a7/action-slack@v3 if: always() with: status: ${{ job.status }} fields: repo,message,author,ref,workflow,took author_name: '' - name: send slack message (URL) uses: 8398a7/action-slack@v3 if: success() with: status: custom custom_payload: | { attachments: [{ text: '<https://myproject-${{ github.ref_name }}.io/|:house:*myproject - ${{ github.ref_name }}*>', }] }
(설명은 앞 글에서 했기에 생략..)
-워크플로우 끝-
이것으로 Vue.js의 GitHub Actions 적용은 끝이다. GitLab에서 직접적으로 CI/CD를 구현해보진 않았지만 GitHub이 편한 것은 확실한 것 같다.
'CICD' 카테고리의 다른 글
[CI/CD] Vue.js GitHub Actions 적용기 #2 (test) (0) 2022.08.16 [CI/CD] Vue.js GitHub Actions 적용기 #1 (prod) (0) 2022.08.06