-
Notifications
You must be signed in to change notification settings - Fork 7
52 lines (50 loc) · 1.64 KB
/
cloud.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
name: Push-to-EC2
# https://lightrains.com/blogs/deploy-aws-ec2-using-github-actions
# Trigger deployment only on push to main branch
on:
push:
branches:
- main
jobs:
deploy:
environment: alibaba
name: Deploy to EC2 on main branch push
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '1.18'
- name: Setup
run: go get -d
- name: Build
run: go build
- name: Setup Web
run: cd web && cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" wasm_exec.js
- name: Build Web
run: cd web && GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o web.wasm && gzip -9 -v -c web.wasm > web.wasm.gz
- name: Deploy
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
REMOTE_HOST: ${{ secrets.HOST_DNS }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}
EXCLUDE: "/.git/, /.github/, main.go, go.mod, go.sum, README.md, LICENSE, screenshot.png, /web/web.wasm"
- name: Run
env:
TARGET: ${{ secrets.TARGET_DIR }}
REMOTE_USER: ${{ secrets.USERNAME }}
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_DNS }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
envs: TARGET
script: |
lsof -i:8080 -t | xargs kill -9
cd $TARGET
nohup ./binalysis -p 8080 > nohup.out 2> nohup.err < /dev/null &