118 lines
4.3 KiB
YAML
Raw Permalink Normal View History

2023-11-18 20:02:23 +01:00
name: CI/CD Pipeline
2024-01-17 19:52:54 +01:00
on: push
2023-11-18 20:02:23 +01:00
env:
2024-02-17 12:48:25 +01:00
CARGO_TARGET: x86_64-unknown-linux-musl
2023-11-18 20:02:23 +01:00
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
jobs:
2024-02-17 12:48:25 +01:00
test:
runs-on: ubuntu-latest
2025-01-10 12:45:19 +01:00
container: git.hofer.link/philipp/ci-images:rust-latest
2024-02-17 12:48:25 +01:00
steps:
- uses: actions/checkout@v3
- name: Run Test DB Script
run: ./test_db.sh
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
2024-02-17 12:48:25 +01:00
- name: Build
run: |
cargo build
cd frontend && npm install && npm run build
- name: Frontend tests
2024-05-12 22:38:25 +02:00
run: cd frontend && npx playwright install && npx playwright test --workers 1 --reporter line
2024-02-17 12:48:25 +01:00
- name: Backend tests
run: cargo test --verbose
#- uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: frontend/playwright-report/
# retention-days: 30
2023-11-18 20:02:23 +01:00
deploy-main:
runs-on: ubuntu-latest
2025-01-10 12:45:19 +01:00
container: git.hofer.link/philipp/ci-images:rust-latest
2024-02-17 12:48:25 +01:00
needs: [test]
2023-11-18 20:02:23 +01:00
if: github.ref == 'refs/heads/main'
2023-11-18 21:46:00 +01:00
steps:
2023-11-18 20:02:23 +01:00
- name: Checkout
uses: actions/checkout@v3
2024-02-17 12:48:25 +01:00
- name: Run Test DB Script
run: ./test_db.sh
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
2024-02-17 12:48:25 +01:00
- name: Build
run: |
cargo build --release --target $CARGO_TARGET
strip target/$CARGO_TARGET/release/rot
cd frontend && npm install && npm run build
2023-11-18 20:02:23 +01:00
2024-12-11 16:24:20 +01:00
- name: Deploy Normannen
2023-11-18 20:02:23 +01:00
run: |
2024-01-17 23:23:58 +01:00
mkdir -p ~/.ssh
2023-11-19 22:01:14 +01:00
ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
2024-12-11 16:24:20 +01:00
scp -C target/$CARGO_TARGET/release/rot $SSH_USER@$SSH_HOST:/home/normannen/rot-updating
scp -C -r static $SSH_USER@$SSH_HOST:/home/normannen/
scp -C -r templates $SSH_USER@$SSH_HOST:/home/normannen/
scp -C -r svelte $SSH_USER@$SSH_HOST:/home/normannen/
ssh $SSH_USER@$SSH_HOST 'mkdir -p /home/normannen/svelte/build'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop normannen'
ssh $SSH_USER@$SSH_HOST 'mv /home/normannen/rot-updating /home/normannen/rot'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl start normannen'
2023-11-18 20:02:23 +01:00
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
2024-12-16 14:26:58 +01:00
- name: Deploy Ister
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/rot $SSH_USER@$SSH_HOST:/home/ister/rot-updating
scp -C -r static $SSH_USER@$SSH_HOST:/home/ister/
scp -C -r templates $SSH_USER@$SSH_HOST:/home/ister/
scp -C -r svelte $SSH_USER@$SSH_HOST:/home/ister/
ssh $SSH_USER@$SSH_HOST 'mkdir -p /home/ister/svelte/build'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop ister'
ssh $SSH_USER@$SSH_HOST 'mv /home/ister/rot-updating /home/ister/rot'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl start ister'
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
2025-01-05 20:25:05 +01:00
- name: Deploy Kufstein
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/rot $SSH_USER@$SSH_HOST:/home/kufstein/rot-updating
scp -C -r static $SSH_USER@$SSH_HOST:/home/kufstein/
scp -C -r templates $SSH_USER@$SSH_HOST:/home/kufstein/
scp -C -r svelte $SSH_USER@$SSH_HOST:/home/kufstein/
ssh $SSH_USER@$SSH_HOST 'mkdir -p /home/kufstein/svelte/build'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl stop kufstein'
ssh $SSH_USER@$SSH_HOST 'mv /home/kufstein/rot-updating /home/kufstein/rot'
ssh $SSH_USER@$SSH_HOST 'sudo systemctl start kufstein'
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}