-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: CI, CD가 작동하지 않았던 부분을 명확하게 하기위해 파일을 분리했습니다.
CD의 경우 PR로 이벤트를 바꿔서 PR에서 작동여부를 체크하겠습니다. ㅠㅠ
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |