-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (39 loc) · 1.23 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
name: Deploy to Raspberry Pi
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Read .nvmrc
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: Install dependencies and build CSS
run: |
npm ci
npm run build
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "StrictHostKeyChecking=no" >> ~/.ssh/config
- name: Compile for Raspberry Pi
run: GOOS=linux GOARCH=arm GOARM=7 go build -o ./cmd/gsvd.dev/tmp/main ./cmd/gsvd.dev
- name: Deploy to Raspberry Pi
run: |
ssh deployer@${{ secrets.PI_HOSTNAME }} 'sudo systemctl stop gsvd.dev.service'
scp ./cmd/gsvd.dev/tmp/main deployer@${{ secrets.PI_HOSTNAME }}:/home/deployer/gsvd.dev
ssh deployer@${{ secrets.PI_HOSTNAME }} 'sudo systemctl start gsvd.dev.service'