-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (49 loc) · 1.65 KB
/
deploy.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: deploy
on:
push:
tags:
- 'v*.*.*'
env:
TAG: ${{github.ref_name}}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_PASS: ${{ secrets.DOCKER_HUB_PASS }}
jobs:
publish-dotnet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build ./Foodie --tag $IMAGE_NAME:$TAG
- name: Publish image
run: |
docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
docker tag $IMAGE_NAME:$TAG $DOCKER_REGISTRY/$IMAGE_NAME:$TAG
docker push $DOCKER_REGISTRY/$IMAGE_NAME:$TAG
deploy:
runs-on: ubuntu-latest
needs: [publish-dotnet]
steps:
- name: setup env and docker compose up
uses: appleboy/ssh-action@master
env:
CERT_KEY_PATH: ${{ secrets.CERT_KEY_PATH }}
CERT_PATH: ${{ secrets.CERT_PATH }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
NGINX_CONF: ${{ secrets.NGINX_CONF }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
envs: TAG,IMAGE_NAME,DOCKER_REGISTRY,CERT_KEY_PATH,CERT_PATH,PRIVATE_KEY,CERTIFICATE,NGINX_CONF
script: |
rm -rf repo
git clone https://github.com/${{github.repository}} repo && cd repo
git fetch origin $TAG
git checkout $TAG
chmod +x ./setup_env.sh
./setup_env.sh
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up -d