-
-
Notifications
You must be signed in to change notification settings - Fork 15
58 lines (56 loc) · 1.75 KB
/
build.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
name: Build
on:
push:
pull_request:
workflow_dispatch:
inputs:
environment:
required: true
type: choice
options:
- terra
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y musl-tools
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- run: cargo build --release --target x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v4
with:
name: lila-tablebase
path: target/x86_64-unknown-linux-musl/release/lila-tablebase
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
concurrency:
group: ${{ inputs.environment }}
needs: build
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v4
with:
name: lila-tablebase
- name: Configure SSH
run: |
mkdir -p ~/.ssh
touch ~/.ssh/deploy.key
chmod 600 ~/.ssh/deploy.key
echo "$SSH_KEY" > ~/.ssh/deploy.key
cat >>~/.ssh/config <<END
Host deploy-host
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/deploy.key
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
- name: Deploy via SSH
run: cat lila-tablebase | ssh deploy-host "mv /usr/local/bin/lila-tablebase /usr/local/bin/lila-tablebase.bak && cat - > /usr/local/bin/lila-tablebase && chmod +x /usr/local/bin/lila-tablebase && systemctl restart lila-tablebase"