-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (55 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
62
name: 'Build and deploy to server'
on:
release:
types: [published]
workflow_dispatch:
jobs:
build:
name: 'Build & Publish'
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v1
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v1
- name: "Login to GitHub Registry"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: "Build & Deploy API"
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/kpihub-server:latest
build-args: |
build_mode=Release
- name: "Run deploy on server"
uses: appleboy/ssh-action@master
env:
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
port: ${{ secrets.SERVER_PORT }}
envs: DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USERNAME, DATABASE_PASSWORD
script: |
cd ~
export DATABASE_HOST=$DATABASE_HOST
export DATABASE_PORT=$DATABASE_PORT
export DATABASE_NAME=$DATABASE_NAME
export DATABASE_USERNAME=$DATABASE_USERNAME
export DATABASE_PASSWORD=$DATABASE_PASSWORD
docker-compose --compatibility -f docker-compose.prod-ci.yml -p prod pull
docker-compose --compatibility -f docker-compose.prod-ci.yml -p prod up -d nginx
sleep 30
docker-compose --compatibility -f docker-compose.prod-ci.yml -p prod run migrate