-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (109 loc) 路 3.36 KB
/
Copy pathdeploy.yaml
File metadata and controls
133 lines (109 loc) 路 3.36 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Deploy
on:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.10.1
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Build server
run: GOOS=linux GOARCH=amd64 go build -o ./bin/server ./cmd/server/main.go
- name: Build CLI
run: GOOS=linux GOARCH=amd64 go build -o ./bin/cli ./cmd/cli/main.go
- name: Set short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Generate config
run: |
cat > ./bin/.config.yaml << EOF
app:
id: "do_fra1"
name: "gopl.dev"
version: "${{ env.SHORT_SHA }}"
env: production
db:
host: localhost
port: 5432
user: gopl
password: "${{ secrets.DB_PASSWORD }}"
name: gopl
log_queries: false
server:
host: "127.0.0.1"
port: 8080
api_base_path: api
addr: "https://gopl.dev/"
autocert_hosts: ""
email:
driver: smtp
from: "mail@gopl.dev"
smtp:
host: "live.smtp.mailtrap.io"
port: 2525
username: "${{ secrets.SMTP_USERNAME }}"
password: "${{ secrets.SMTP_PASSWORD }}"
session:
duration_hours: 120
key: "${{ secrets.SESSION_KEY }}"
tracing:
enabled: true
driver: uptrace
uptrace_dsn: "${{ secrets.UPTRACE_DSN }}"
files:
storage_driver: 'local-fs'
max_upload_size_mb: 20
image_max_width: 3000
image_max_height: 3000
preview_width: 400
preview_height: 400
local_fs:
storage_path: "/files"
entities:
books:
covers:
path: "book-covers"
openapi:
enabled: true
serve_path: openapi
google_oauth:
client_id: "${{ secrets.GOOGLE_CLIENT_ID }}"
client_secret: "${{ secrets.GOOGLE_CLIENT_SECRET }}"
github_oauth:
client_id: "${{ secrets.GH_CLIENT_ID }}"
client_secret: "${{ secrets.GH_CLIENT_SECRET }}"
admins: ["019c7a4b-1931-7adb-8e21-70044db68daf"]
EOF
- name: Upload files to droplet
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_SSH_HOST }}
username: ${{ secrets.DEPLOY_SSH_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
source: "bin/server,bin/cli,bin/.config.yaml"
target: "/opt/gopl/"
strip_components: 1
- name: Restart service
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_SSH_HOST }}
username: ${{ secrets.DEPLOY_SSH_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
chmod +x /opt/gopl/server
chmod +x /opt/gopl/cli
sudo systemctl restart gopl