CI/CD test #1
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 Deployment | |
on: | |
push: | |
paths: | |
- "BE/**" | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Registry | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build and Push Docker Image | |
run: | | |
docker build -t your-username/your-backend-image:latest ./BE | |
docker push your-username/your-backend-image:latest | |
- name: Deploy to Naver Cloud Platform | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa user@your-server "docker pull your-username/your-backend-image:latest && docker stop your-container-name || true && docker rm your-container-name || true && docker run -d --name your-container-name your-username/your-backend-image:latest" |