Skip to content

Commit

Permalink
ci: CI, CD가 작동하지 않았던 부분을 명확하게 하기위해 파일을 분리했습니다.
Browse files Browse the repository at this point in the history
CD의 경우 PR로 이벤트를 바꿔서 PR에서 작동여부를 체크하겠습니다. ㅠㅠ
wonholim committed Nov 20, 2023
1 parent 5008f82 commit d17a66e
Showing 2 changed files with 66 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/BackEnd_CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: BackEnd-CD

on:
pull_request:
branches: 'develop'
types: [opened, synchronize, reopened]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}

- uses: docker/build-push-action@v3
with:
context: .
file: ./BackEnd/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest

- name: SSH Tunneling and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BASTION_HOST }}
username: ${{ secrets.BASTION_USER }}
key: ${{ secrets.BASTION_SSH_KEY }}
script: |
ssh -o StrictHostKeyChecking=no -L 9999:${{ secrets.INTERNAL_SERVER_IP }}:22 ${{ secrets.BASTION_USER }}@localhost -i ${{ secrets.BASTION_SSH_PRIVATE_KEY_PATH }} -fN
ssh -o StrictHostKeyChecking=no -p 9999 ${{ secrets.SERVER_USER }}@localhost -i ${{ secrets.SERVER_SSH_PRIVATE_KEY_PATH }} '
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
docker stop my-app || true
docker rm my-app || true
docker run --name my-app -d -p 3000:3000 --env-file /var/env/.env ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
'
26 changes: 26 additions & 0 deletions .github/workflows/BackEnd_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: BackEnd-CI

on:
pull_request:
branches: 'develop'
types: [opened, synchronize, reopened, edited]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: 코드 체크아웃
uses: actions/checkout@v3

- name: node 세팅
uses: actions/setup-node@v2
with:
node-version: '18'

- name: 의존성 설치
run: npm ci
working-directory: ./BackEnd

- name: 테스트 진행
run: npm test
working-directory: ./BackEnd

0 comments on commit d17a66e

Please sign in to comment.