-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 1.52 KB
/
deploy.yml
File metadata and controls
61 lines (52 loc) · 1.52 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
name: deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: self-hosted
environment: Raspberry Pi 5
env:
APP_NAME: discit-api-refresh
APP_DIR: /home/pi/apps/discit-api-refresh
ENV_DIR: /home/pi/.env/discit-api-refresh
LOG_FILE: refresh.log
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies and lint project
run: |
bun install --ignore-scripts --frozen-lockfile
bun run biome ci .
- name: Compile app to standalone binary
run: bun run compile
- name: Copy files to app directory
run: |
rm -rf $APP_DIR && mkdir $APP_DIR
cp main $APP_DIR/main
cp $ENV_DIR/.env $APP_DIR/.env
- name: Install/update systemd service to run app
run: |
cat > /tmp/$APP_NAME.service << EOF
[Unit]
Description=$APP_NAME
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=$APP_DIR
ExecStart=$APP_DIR/main
StandardOutput=append:$ENV_DIR/$LOG_FILE
StandardError=inherit
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo mv /tmp/$APP_NAME.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable $APP_NAME.service
sudo systemctl restart $APP_NAME.service
sudo systemctl status $APP_NAME.service