-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (53 loc) · 2.15 KB
/
deploy-front.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
58
59
name: auto deploy front
on:
push:
branches:
- dev
jobs:
docker_push_front:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to NCP Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
context: ./client
file: ./client/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/front
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/front
cache-to: type=inline
build-args: |
VITE_API_URL=${{ secrets.VITE_API_URL }}
VITE_HLS_URL=${{ secrets.VITE_HLS_URL }}
docker_pull_front:
name: Connect server ssh and pull frontend from container registry
needs: docker_push_front
runs-on: ubuntu-latest
steps:
- name: connect ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.FRONT_HOST }}
username: ${{ secrets.FRONT_USERNAME }}
password: ${{ secrets.FRONT_PASSWORD }}
port: ${{ secrets.FRONT_PORT }}
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/front
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 80:80 -p 443:443 --name front ${{ secrets.NCP_CONTAINER_REGISTRY }}/front
docker image prune -f
docker cp /etc/letsencrypt/archive/gbs-live.site/fullchain1.pem front:/
docker cp /etc/letsencrypt/archive/gbs-live.site/privkey1.pem front:/
docker cp default.conf front:/etc/nginx/conf.d/
docker exec front nginx -s reload