Skip to content

Commit e354bf6

Browse files
committed
[cicd] : workflow 스크립트, 도커파일 추가
1 parent 63667c5 commit e354bf6

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.github/workflows/cicd.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# github repository actions 페이지에 나타날 이름
2+
name: CI/CD for front using github actions
3+
4+
# event trigger
5+
# develop 브랜치에 pull_request가 닫히거나 푸시했을때 실행
6+
on:
7+
pull_request:
8+
types: [closed]
9+
branches: [ "develop" ]
10+
push:
11+
branches: [ "develop" ]
12+
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
front-cicd:
19+
runs-on: ubuntu-latest
20+
steps:
21+
# 저장소 코드를 체크아웃합니다. (PR 올린 코드를 가져오는 행위)
22+
- uses: actions/checkout@v4
23+
24+
# Node.js 환경 설정
25+
- name: Use Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22 # 지정된 Node.js 버전 사용
29+
cache: npm # setup-node 의 캐시 기능을 사용함
30+
cache-dependency-path: package-lock.json # 캐시 기능을 사용할 때 캐시의 기준이 될 파일을 지정
31+
32+
- name: Install Dependencies
33+
run: npm install
34+
35+
- name: Build with npm
36+
run: npm run build
37+
38+
- name: Create nginx.conf
39+
run: touch ./nginx.conf
40+
- run: echo "${{ secrets.NGINX_CONF }}" > ./nginx.conf
41+
42+
## docker build & push to production
43+
- name: Docker build & push
44+
run: |
45+
docker login clap.kr-central-2.kcr.dev -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
46+
docker build -t ${{ secrets.DOCKER_FRONT_REPO }} .
47+
docker push ${{ secrets.DOCKER_FRONT_REPO }}
48+
49+
## deploy
50+
- name: Deploy
51+
uses: appleboy/ssh-action@master
52+
id: deploy
53+
with:
54+
host: ${{ secrets.FRONT_HOST }}
55+
username: ${{ secrets.FRONT_HOST_USERNAME }}
56+
key: ${{ secrets.FRONT_HOST_KEY }}
57+
port: ${{ secrets.FRONT_HOST_PORT }}
58+
script: |
59+
docker rm -f taskflow-front
60+
docker image rm ${{ secrets.DOCKER_FRONT_REPO }} -f
61+
docker run --name taskflow-front -d -p 80:80 ${{ secrets.DOCKER_FRONT_REPO }} --restart on-failure

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM nginx
2+
COPY nginx.conf /etc/nginx/nginx.conf
3+
COPY dist/* /usr/share/nginx/html/
4+
EXPOSE 80
5+
CMD ["nginx", "-g", "daemon on;"]

0 commit comments

Comments
 (0)