name: CI/CD Pipeline on: push env: CARGO_TARGET: x86_64-unknown-linux-musl SSH_HOST: ${{ secrets.SSH_HOST }} SSH_USER: ${{ secrets.SSH_USER }} SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} jobs: test: runs-on: ubuntu-latest container: git.hofer.link/philipp/ci-images:rust-latest steps: - 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 cd frontend && npm install && npm run build - name: Frontend tests run: cd frontend && npx playwright install && npx playwright test --workers 1 --reporter line - 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 deploy-main: 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 cd frontend && npm install && npm run build - name: Deploy Normannen 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/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' env: SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} SSH_HOST: ${{ secrets.SSH_HOST }} SSH_USER: ${{ secrets.SSH_USER }} - 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 }} - 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 }}