Skip to content

Update container_registry.yml #14

Update container_registry.yml

Update container_registry.yml #14

Workflow file for this run

name: the ultimate CI/CD pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Kakao Cloud Container Registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.KAKAO_CLOUD_PROJECT_NAME }}.kr-central-2.kcr.dev
username: ${{ secrets.KAKAO_CLOUD_ACCESS_KEY }}
password: ${{ secrets.KAKAO_CLOUD_ACCESS_SECRET_KEY }}
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.KAKAO_CLOUD_PROJECT_NAME }}.kr-central-2.kcr.dev/${{ secrets.KAKAO_CLOUD_REPOSITORY_NAME }}/lifebook:latest
# ssh로 서버에 접속해서 기존의 컨테이너를 삭제하고 새로운 컨테이너를 실행
- name: SSH to the server
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
script: |
docker stop $(docker ps -q)
docker rmi -f $(docker images -aq)
docker pull ${{ secrets.KAKAO_CLOUD_PROJECT_NAME }}.kr-central-2.kcr.dev/${{ secrets.KAKAO_CLOUD_REPOSITORY_NAME }}/lifebook:latest
docker run -e DB_PORT=$DB_PORT -e DB_DB=$DB_DB -e DB_HOST=$DB_HOST -e DB_PASSWORD=$DB_PASSWORD -e DB_USER=$DB_USER -e OPEN_API_KEY=$OPEN_API_KEY -d -p 8080:8000 ${{ secrets.KAKAO_CLOUD_PROJECT_NAME }}.kr-central-2.kcr.dev/${{ secrets.KAKAO_CLOUD_REPOSITORY_NAME }}/lifebook:latest