-
Notifications
You must be signed in to change notification settings - Fork 14
81 lines (76 loc) · 2.96 KB
/
front-cicd.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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 '/*'