Merge pull request #271 from boostcampwm2023/test/230-test-db-refactor #28
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: Build and Push Backend | |
on: | |
push: | |
paths: | |
- "BE/**" | |
branches: | |
- main | |
jobs: | |
build-and-push-backend: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
- name: Login to NCP Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: byeolsoop-registry.kr.ncr.ntruss.com | |
username: ${{ secrets.API_ACCESS_KEY }} | |
password: ${{ secrets.API_SECRET_KEY }} | |
- name: Build and Push Backend Docker Image | |
run: | | |
docker build -t byeolsoop-registry.kr.ncr.ntruss.com/backend:byeolsoop -f ./docker/be/Dockerfile . | |
docker push byeolsoop-registry.kr.ncr.ntruss.com/backend:byeolsoop | |
pull-and-deploy: | |
needs: build-and-push-backend | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: SSH-deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{secrets.VPC_HOST}} | |
username: ${{secrets.VPC_USER}} | |
password: ${{secrets.VPC_PASSWORD}} | |
port: ${{secrets.VPC_PORT}} | |
script: | | |
cd /home/docker-byeolsoop/srcs | |
docker system prune -f | |
docker pull byeolsoop-registry.kr.ncr.ntruss.com/backend:byeolsoop | |
docker compose up --force-recreate -d 2>log.out | |
cat log.out |