-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (52 loc) · 1.63 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
58
59
60
61
62
name: Go Test Build and Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.4
- name: Test
run: go test -v ./...
- name: Build
run: go build -v -o api ./cmd/api
- uses: actions/upload-artifact@v3
with:
name: sw-artifact
path: ./api
deploy:
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: sw-artifact
- name: Deploy to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: ./api
target: "/home/${{ secrets.USERNAME }}/chess/swahilichess-api"
- name: Start SwahiliChess API service and Reload Nginx
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /home/${{ secrets.USERNAME }}/chess/swahilichess-api
chmod +x api
echo ${{ secrets.PASSWORD }} | sudo -S systemctl stop swahiliches-api.service
echo ${{ secrets.PASSWORD }} | sudo -S systemctl start swahiliches-api.service
echo ${{ secrets.PASSWORD }} | sudo -S systemctl reload nginx