-
Notifications
You must be signed in to change notification settings - Fork 1
36 lines (29 loc) · 988 Bytes
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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