feat: ipa 제공을 위한 index.html 서빙 코드 작성 #10
Workflow file for this run
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 | ||
name: BackEnd-CD | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- 'BackEnd/**' | ||
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 to Internal Server and Deploy | ||
env: | ||
BASTION_HOST: ${{ secrets.BASTION_HOST }} | ||
BASTION_USER: ${{ secrets.BASTION_USER }} | ||
BASTION_PASSWORD: ${{ secrets.BASTION_PASSWORD }} | ||
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} | ||
SERVER_USER: ${{ secrets.SERVER_USER }} | ||
INTERNAL_SERVER_IP: ${{ secrets.INTERNAL_SERVER_IP }} | ||
CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }} | ||
run: | | ||
sshpass -p $BASTION_PASSWORD ssh -o StrictHostKeyChecking=no $BASTION_USER@$BASTION_HOST -tt << EOF | ||
sshpass -p $SERVER_PASSWORD ssh -o StrictHostKeyChecking=no $SERVER_USER@$INTERNAL_SERVER_IP -tt << 'ENDSSH' | ||
docker pull $CONTAINER_REGISTRY/my-app:latest | ||
docker stop my-app || true | ||
docker rm my-app || true | ||
docker run --name my-app -d -p 443:3000 -p 80:3000 $CONTAINER_REGISTRY/my-app:latest | ||
docker cp /var/env/.env my-app:/app/.env | ||
ENDSSH | ||
EOF |