Skip to content

Commit f96266a

Browse files
authored
🛠️ CI/CD 파이프라인 구축 (#5)
node_modules를 통한 의존성 관리 -> 추후 변경 예정 #6 vitest와 eslint를 이용하여 CI Pipeline 구축 docker와 EC2를 이용하여 CD Pipeline 구축 Closes #PW-248
1 parent f3fe03f commit f96266a

29 files changed

+3626
-22744
lines changed

.github/actions/setup/action.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: 'Reuse Setup Action'
2+
description: 'Setup node, yarn, dependencies'
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
# 1. 브런치 코드 내려받기
8+
- name: Checkout
9+
uses: actions/checkout@v4
10+
11+
# 2. 노드 버전 18.18.0 설치
12+
- name: Setup node 18.18.0
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 18.18.0
16+
cache: yarn
17+
18+
# 3. yarn 버전 설정
19+
- name: Setup yarn version
20+
shell: bash
21+
run: yarn set version 1.22.19
22+
23+
# 4. yarn 캐시 경로 불러오기
24+
- name: Get cache dir path
25+
shell: bash
26+
id: yarn-cache-dir-path
27+
run: echo "CACHE_DIR=$(yarn cache dir)" >> $GITHUB_ENV
28+
29+
# 5. yarn 패키지 캐싱
30+
- name: Cache yarn packages
31+
uses: actions/cache@v2
32+
id: yarn-cache
33+
with:
34+
path: $CACHE_DIR
35+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ env.YARN_VERSION }}
36+
37+
# 6. 패키지 캐싱 확인 후 설치
38+
- name: Install dependencies
39+
shell: bash
40+
run: |
41+
CACHE_HIT="${{ steps.yarn-cache.outputs.cache-hit }}"
42+
NODE_MODULES_EXISTS=$(test -d "node_modules" && echo "true" || echo "false")
43+
if [[ "$CACHE_HIT" != 'true' || "$NODE_MODULES_EXISTS" == 'false' ]]; then
44+
yarn install
45+
fi

.github/workflows/deploy.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Continuous Deployment
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
workflow_dispatch:
7+
inputs:
8+
logLevel:
9+
description: 'Log level'
10+
required: true
11+
default: 'warning'
12+
type: choice
13+
options:
14+
- info
15+
- warning
16+
- debug
17+
tags:
18+
description: 'Test scenario tags'
19+
required: false
20+
type: boolean
21+
environment:
22+
description: 'Environment to run tests against'
23+
type: environment
24+
required: false
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
deployment:
31+
runs-on: ubuntu-20.04
32+
33+
steps:
34+
- name: Checkout pull request
35+
uses: actions/checkout@v4
36+
37+
- name: Reuse setup action
38+
uses: ./.github/actions/setup
39+
40+
# 7. Yarn 빌드 파일 생성
41+
- name: Yarn build
42+
run: yarn build
43+
44+
# 8. Docker 이미지 build 및 push
45+
- name: Docker build and push
46+
run: |
47+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
48+
docker build -t pennyway/pennyway-webview .
49+
docker push pennyway/pennyway-webview
50+
51+
# 9. AWS SSM을 통한 Run-Command
52+
- name: AWS SSM Send-Command
53+
uses: peterkimzz/aws-ssm-send-command@master
54+
id: ssm
55+
with:
56+
aws-region: ${{ secrets.AWS_REGION }}
57+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
58+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
59+
instance-ids: ${{ secrets.AWS_DEV_INSTANCE_ID }}
60+
working-directory: /home/ubuntu
61+
command: |
62+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
63+
docker stop webview
64+
docker system prune -a -f
65+
docker pull pennyway/pennyway-webview
66+
docker run --name "webview" -d -p 3000:3000 pennyway/pennyway-webview

.github/workflows/test.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches: ['main']
6+
workflow_dispatch:
7+
inputs:
8+
logLevel:
9+
description: 'Log level'
10+
required: true
11+
default: 'warning'
12+
type: choice
13+
options:
14+
- info
15+
- warning
16+
- debug
17+
tags:
18+
description: 'Test scenario tags'
19+
required: false
20+
type: boolean
21+
environment:
22+
description: 'Environment to run tests against'
23+
type: environment
24+
required: false
25+
26+
jobs:
27+
lint:
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- name: Checkout pull request
31+
uses: actions/checkout@v4
32+
33+
- name: Reuse setup action
34+
uses: ./.github/actions/setup
35+
36+
- name: Test with eslint
37+
run: yarn lint
38+
39+
test:
40+
runs-on: ubuntu-20.04
41+
steps:
42+
- name: Checkout pull request
43+
uses: actions/checkout@v4
44+
45+
- name: Reuse setup action
46+
uses: ./.github/actions/setup
47+
48+
- name: Test with vitest
49+
run: yarn test

.gitignore

+19-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@ dist-ssr
2727
.yarn/install-state.gz
2828

2929
# env
30-
.env
30+
.env
31+
32+
# not used zero-install
33+
.yarn/*
34+
!.yarn/patches
35+
!.yarn/releases
36+
!.yarn/plugins
37+
!.yarn/sdks
38+
!.yarn/versions
39+
.pnp.*
40+
41+
# # used zero-install
42+
# .yarn/*
43+
# !.yarn/cache
44+
# !.yarn/patches
45+
# !.yarn/plugins
46+
# !.yarn/releases
47+
# !.yarn/sdks
48+
# !.yarn/versions

0 commit comments

Comments
 (0)