add deployment
This commit is contained in:
parent
17690d7e6f
commit
472ac97a4d
@ -23,3 +23,40 @@ jobs:
|
|||||||
|
|
||||||
- name: Backend tests
|
- name: Backend tests
|
||||||
run: cargo test --verbose
|
run: cargo test --verbose
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: git.hofer.link/philipp/ci-images:rust-latest
|
||||||
|
needs: [test]
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Run Test DB Script
|
||||||
|
run: ./test_db.sh
|
||||||
|
|
||||||
|
- name: Cache Cargo dependencies
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cargo build --release --target $CARGO_TARGET
|
||||||
|
strip target/$CARGO_TARGET/release/rot
|
||||||
|
|
||||||
|
- name: Deploy to production
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
|
||||||
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
|
||||||
|
scp -C target/$CARGO_TARGET/release/stationslauf $SSH_USER@$SSH_HOST:/home/stationslauf/stationslauf-updating
|
||||||
|
ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop stationslauf'
|
||||||
|
ssh $SSH_USER@$SSH_HOST 'mv /home/stationslauf/stationslauf-updating /home/stationslauf/stationslauf'
|
||||||
|
ssh $SSH_USER@$SSH_HOST 'sudo systemctl start stationslauf'
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||||
|
SSH_USER: ${{ secrets.SSH_USER }}
|
||||||
|
|
||||||
|
18
stationslauf.service
Normal file
18
stationslauf.service
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Stationslauf
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
WorkingDirectory=/home/stationslauf
|
||||||
|
Environment="PORT=7001"
|
||||||
|
Environment="RUST_LOG=info"
|
||||||
|
Environment="DATABASE_URL=sqlite:///home/stationslauf/db.sqlite"
|
||||||
|
ExecStart=/home/stationslauf/stationslauf
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user