[GWL-213] posts 테스트 코드 작성 및 리팩토링 (#256) #6
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
name: BackEnd-CD | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- 'BackEnd/**' | |
jobs: | |
deploy: | |
runs-on: self-hosted | |
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 | |
platforms: linux/amd64 | |
- name: SSH to Internal Server and Deploy | |
run: | | |
sshpass -p ${{ secrets.BASTION_PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.BASTION_USER }}@${{ secrets.BASTION_HOST }} -tt " | |
sshpass -p ${{ secrets.SERVER_PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.INTERNAL_SERVER_IP }} ' | |
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 -p 3003:3003 ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest; | |
docker cp /var/env/.env my-app:/app/.env; | |
'" |