Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️ CI/CD 파이프라인 구축 #5

Merged
merged 17 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'Reuse Setup Action'
description: 'Setup node, yarn, dependencies'

runs:
using: 'composite'
steps:
# 1. 브런치 코드 내려받기
- name: Checkout
uses: actions/checkout@v4

# 2. 노드 버전 18.18.0 설치
- name: Setup node 18.18.0
uses: actions/setup-node@v4
with:
node-version: 18.18.0
cache: yarn

# 3. yarn 버전 설정
- name: Setup yarn version
shell: bash
run: yarn set version 1.22.19

# 4. yarn 캐시 경로 불러오기
- name: Get cache dir path
shell: bash
id: yarn-cache-dir-path
run: echo "CACHE_DIR=$(yarn cache dir)" >> $GITHUB_ENV

# 5. yarn 패키지 캐싱
- name: Cache yarn packages
uses: actions/cache@v2
id: yarn-cache
with:
path: $CACHE_DIR
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ env.YARN_VERSION }}

# 6. 패키지 캐싱 확인 후 설치
- name: Install dependencies
shell: bash
run: |
CACHE_HIT="${{ steps.yarn-cache.outputs.cache-hit }}"
NODE_MODULES_EXISTS=$(test -d "node_modules" && echo "true" || echo "false")
if [[ "$CACHE_HIT" != 'true' || "$NODE_MODULES_EXISTS" == 'false' ]]; then
yarn install
fi
66 changes: 66 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Continuous Deployment

on:
push:
BangDori marked this conversation as resolved.
Show resolved Hide resolved
branches: ['main']
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: false

permissions:
contents: read

jobs:
deployment:
runs-on: ubuntu-20.04

steps:
- name: Checkout pull request
uses: actions/checkout@v4

- name: Reuse setup action
uses: ./.github/actions/setup

# 7. Yarn 빌드 파일 생성
- name: Yarn build
run: yarn build

# 8. Docker 이미지 build 및 push
- name: Docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t pennyway/pennyway-webview .
docker push pennyway/pennyway-webview

# 9. AWS SSM을 통한 Run-Command
- name: AWS SSM Send-Command
uses: peterkimzz/aws-ssm-send-command@master
id: ssm
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
instance-ids: ${{ secrets.AWS_DEV_INSTANCE_ID }}
working-directory: /home/ubuntu
command: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker stop webview
docker system prune -a -f
docker pull pennyway/pennyway-webview
docker run --name "webview" -d -p 3000:3000 pennyway/pennyway-webview
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Continuous Integration

on:
pull_request:
branches: ['main']
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: false

jobs:
lint:
runs-on: ubuntu-20.04
steps:
- name: Checkout pull request
uses: actions/checkout@v4

- name: Reuse setup action
uses: ./.github/actions/setup

- name: Test with eslint
run: yarn lint

test:
runs-on: ubuntu-20.04
steps:
- name: Checkout pull request
uses: actions/checkout@v4

- name: Reuse setup action
uses: ./.github/actions/setup

- name: Test with vitest
run: yarn test
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,22 @@ dist-ssr
.yarn/install-state.gz

# env
.env
.env

# not used zero-install
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# # used zero-install
# .yarn/*
# !.yarn/cache
# !.yarn/patches
# !.yarn/plugins
# !.yarn/releases
# !.yarn/sdks
# !.yarn/versions
Loading
Loading