Skip to content

CI/CD

CI/CD #1704

Workflow file for this run

name: CI/CD
on:
push:
paths:
- "frontend/**"
workflow_dispatch:
jobs:
frontend-CI:
runs-on: ubuntu-latest
steps:
- name: Make ssh file
run: |
mkdir -p ~/.ssh
echo '${{ secrets.SSH_CONFIG }}' | base64 -d > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
- name: 체크아웃
uses: actions/checkout@v3
with:
submodule: true
- name: 서브모듈 업데이트
run: |
git submodule update --init config
- name: Node.js 16.x Version
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: 종속 모듈들 캐싱
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/frontend/node_modules
key: npm-packages-${{ hashFiles('**/frontend/package-lock.json') }}
id: cache
- name: 종속 모듈들 설치
if: steps.cache.outputs.cache-hit != 'true'
run: npm install --prefix frontend
# - name: lint 체크
# run: npm run lint --prefix frontend
- name: Dev env 파일 생성
if: ${{ github.ref == 'refs/heads/dev' }}
run: cat ./config/frontend/dev.env > ./frontend/.env
- name: Main env 파일 생성
if: ${{ github.ref == 'refs/heads/main' }}
run: cat ./config/frontend/main.env > ./frontend/.env
- name: 빌드 체크
run: npm run build --prefix frontend
# - name: 단위 테스트 체크
# run: npm run test --prefix frontend
# - name: 통합 테스트 체크
# run: npm run test:e2e --prefix frontend
- name: Configure AWS credentials
if: ${{ github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' }}
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: ${{ secrets.AWS_REGION }}
- name: Dev S3에 배포 및 CloudFront 캐시 무효화
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
cd frontend
mkdir -p dist/src/Cabinet/assets
mkdir -p dist/src/Presentation/assets
cp -r src/Cabinet/assets/images dist/src/Cabinet/assets
cp -r src/Presentation/assets/images dist/src/Presentation/assets
aws s3 sync ./dist s3://dev.cabi
aws cloudfront create-invalidation --distribution-id EWPTW52IH5L5C --paths '/*'
- name: Main S3에 배포 및 CloudFront 캐시 무효화
if: ${{ github.ref == 'refs/heads/main' }}
run: |
cd frontend
mkdir -p dist/src/Cabinet/assets
mkdir -p dist/src/Presentation/assets
cp -r src/Cabinet/assets/images dist/src/Cabinet/assets
cp -r src/Presentation/assets/images dist/src/Presentation/assets
aws s3 sync ./dist s3://42cabi
aws cloudfront create-invalidation --distribution-id E12WMB9HCNB1DT --paths '/*'