-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (66 loc) · 2.1 KB
/
dev-deploy.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Rust
on:
push:
branches: [ "main" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://postgres@localhost/food_calc_testing
BIN_NAME: "backend"
jobs:
test:
runs-on: ubuntu-latest
environment: ssh
services:
postgres:
image: postgres:alpine
env:
POSTGRES_DB: food_calc_testing
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=de-DE --locale=de_DE.UTF-8 --encoding=UTF8 --data-checksums"
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install SQLX
run: cargo install sqlx-cli
- name: Apply Database Migrations
run: |
for migration in $(find ./foodlib/migrations/ -type f | sort)
do
psql -p 5432 -h 127.0.0.1 -U postgres --no-password -f $migration food_calc_testing
done
- name: Install NPM Dependencies
run: cd backend && npm install && cd ..
- name: Install Tectonic Dependencies
run: sudo apt install libgraphite2-dev
- name: Run tests
run: cargo test --all
deploy:
runs-on: ubuntu-latest
environment: ssh
needs: test
steps:
- uses: actions/checkout@v3
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_PORT: ${{ secrets.DEPLOY_PORT }}
SOURCE: ./
TARGET: /srv/foodcalc/build
SCRIPT_AFTER: |
echo $RSYNC_STDOUT
cd /srv/foodcalc/build/backend && npm install
cd /srv/foodcalc/build/
cargo build --release --bin ${{ env.BIN_NAME }} --features tectonic
sudo /bin/systemctl stop foodcalc
cp /srv/foodcalc/build/target/release/${{ env.BIN_NAME }} /srv/foodcalc/${{ env.BIN_NAME }}
sudo /bin/systemctl start foodcalc