-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (57 loc) · 2.09 KB
/
main.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
60
61
name: auto deploy
on:
push:
branches:
- feature/51-ncp-deploy
jobs:
push_to_registry:
name: Push to ncp container registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- 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
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/backend:latest
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/prv-backend:latest
cache-to: type=inline
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GIT_TOKEN }}
pull_from_registry:
name: Connect server ssh and pull from container registry
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: connect ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USERNAME }}
password: ${{ secrets.DEV_PASSWORD }}
port: ${{ secrets.DEV_PORT }}
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/backend
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 3000:80 \
-e DB_HOST='${{ secrets.DB_HOST }}' \
-e DB_PORT='${{ secrets.DB_PORT }}' \
-e DB_USERNAME='${{ secrets.DB_USERNAME }}' \
-e DB_PASSWORD='${{ secrets.DB_PASSWORD }}' \
-e DB_DATABASE='${{ secrets.DB_DATABASE }}' \
-e JWT_SECRET_KEY='${{ secrets.JWT_SECRET_KEY }}' \
-e API_BASE_URL='${{ secrets.API_BASE_URL }}' \
${{ secrets.NCP_CONTAINER_REGISTRY }}/backend
docker image prune -f