Skip to content

Commit 4411522

Browse files
Merge pull request #64 from TaskFlow-CLAP/CLAP-104
CLAP-104 깃허브액션 dev 환경 ci/cd 스크립트 병합
2 parents 2accfdb + dae62c0 commit 4411522

File tree

2 files changed

+74
-46
lines changed

2 files changed

+74
-46
lines changed

.github/workflows/dev-cd.yml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
# github repository actions 페이지에 나타날 이름
2-
name: CD to dev using github actions
3-
4-
# event trigger
5-
# develop 브랜치에 pull_request가 닫혔을 때 실행
6-
on:
7-
pull_request:
8-
types: [ closed ]
9-
branches: [ "develop" ]
10-
11-
permissions:
12-
contents: read
13-
14-
jobs:
15-
DEV-CD:
16-
if: github.event.pull_request.merged == true
17-
runs-on: ubuntu-latest
18-
steps:
19-
- name: Download build artifacts
20-
uses: actions/download-artifact@v4
21-
with:
22-
name: build-artifacts
23-
github-token: ${{ secrets.GH_TOKEN }}
24-
25-
## docker build & push to production
26-
- name: Docker build & push to prod
27-
run: |
28-
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
29-
docker build -t ${{ secrets.DOCKER_REPO }} .
30-
docker push ${{ secrets.DOCKER_REPO }}
31-
32-
## deploy to dev
33-
- name: Deploy to prod
34-
uses: appleboy/ssh-action@master
35-
id: deploy
36-
with:
37-
host: ${{ secrets.DEV_HOST }}
38-
username: ${{ secrets.DEV_HOST_USERNAME }}
39-
key: ${{ secrets.DEV_HOST_KEY }}
40-
port: ${{ secrets.DEV_HOST_PORT }}
41-
script: |
42-
docker rm -f taskflow
43-
docker image rm ${{ secrets.DOCKER_REPO }} -f
44-
docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure
1+
## github repository actions 페이지에 나타날 이름
2+
#name: CD to dev using github actions
3+
#
4+
## event trigger
5+
## develop 브랜치에 pull_request가 닫혔을 때 실행
6+
#on:
7+
# pull_request:
8+
# types: [ closed ]
9+
# branches: [ "develop" ]
10+
#
11+
#permissions:
12+
# contents: read
13+
#
14+
#jobs:
15+
# DEV-CD:
16+
# if: github.event.pull_request.merged == true
17+
# runs-on: ubuntu-latest
18+
# steps:
19+
# - name: Download build artifacts
20+
# uses: actions/download-artifact@v4
21+
# with:
22+
# name: build-artifacts
23+
# github-token: ${{ secrets.GH_TOKEN }}
24+
#
25+
# ## docker build & push to production
26+
# - name: Docker build & push to prod
27+
# run: |
28+
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
29+
# docker build -t ${{ secrets.DOCKER_REPO }} .
30+
# docker push ${{ secrets.DOCKER_REPO }}
31+
#
32+
# ## deploy to dev
33+
# - name: Deploy to prod
34+
# uses: appleboy/ssh-action@master
35+
# id: deploy
36+
# with:
37+
# host: ${{ secrets.DEV_HOST }}
38+
# username: ${{ secrets.DEV_HOST_USERNAME }}
39+
# key: ${{ secrets.DEV_HOST_KEY }}
40+
# port: ${{ secrets.DEV_HOST_PORT }}
41+
# script: |
42+
# docker rm -f taskflow
43+
# docker image rm ${{ secrets.DOCKER_REPO }} -f
44+
# docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure

.github/workflows/dev-ci.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# github repository actions 페이지에 나타날 이름
2-
name: CI for dev using github actions
2+
name: CI/CD to dev using github actions
33

44
# event trigger
55
# develop 브랜치에 pull_request가 열렸을 때 실행
@@ -47,4 +47,32 @@ jobs:
4747
uses: actions/upload-artifact@v4
4848
with:
4949
name: build-artifacts
50-
path: build/libs/*.jar
50+
path: build/libs/*.jar
51+
52+
DEV-CD:
53+
if: github.event.action == 'closed' && github.event.pull_request.merged == true
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Download build artifacts
57+
uses: actions/download-artifact@v4
58+
with:
59+
name: build-artifacts
60+
github-token: ${{ secrets.GH_TOKEN }}
61+
62+
- name: Docker build & push to prod
63+
run: |
64+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
65+
docker build -t ${{ secrets.DOCKER_REPO }} .
66+
docker push ${{ secrets.DOCKER_REPO }}
67+
68+
- name: Deploy to dev
69+
uses: appleboy/ssh-action@master
70+
with:
71+
host: ${{ secrets.DEV_HOST }}
72+
username: ${{ secrets.DEV_HOST_USERNAME }}
73+
key: ${{ secrets.DEV_HOST_KEY }}
74+
port: ${{ secrets.DEV_HOST_PORT }}
75+
script: |
76+
docker rm -f taskflow || true
77+
docker image rm ${{ secrets.DOCKER_REPO }} -f || true
78+
docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure

0 commit comments

Comments
 (0)