Skip to content

CD

CD #19

Workflow file for this run

name: CD
env:
DOCKER_IMAGE: ghcr.io/likelion-knu04/mealog-web
DOCKER_CONTAINER: mealog-web
on:
workflow_run:
workflows: ['CI']
types:
- completed
jobs:
deploy:
name: Deploy
runs-on: self-hosted
steps:
- name: Login to ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Pull Docker image
run: sudo docker pull ${{ env.DOCKER_IMAGE }}:latest
- name: Delete old Docker container and image
run: |
docker stop ${{ env.DOCKER_CONTAINER }} || true
docker rm -f ${{ env.DOCKER_CONTAINER }} || true
docker rmi ${{ env.DOCKER_IMAGE }}:latest || true
- name: Run Docker container
run: sudo docker run -d -p 3000:3000 --name ${{ env.DOCKER_CONTAINER }} --restart always --hostname ${{ env.DOCKER_CONTAINER }} --network web ${{ env.DOCKER_IMAGE }}:latest