crawlnicle/.github/workflows/deploy.yml

67 lines
1.7 KiB
YAML
Raw Normal View History

name: Deploy
on:
push:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
2023-10-20 03:54:06 +00:00
- name: Cache Cargo binaries
uses: actions/cache@v3
with:
path: ~/.cargo/bin
2023-10-20 04:18:03 +00:00
key: ${{ runner.os }}-cargo-bin
2023-10-20 03:54:06 +00:00
2023-10-20 04:12:38 +00:00
- uses: extractions/setup-just@v1
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install frontend
run: bun install --frozen-lockfile --cwd frontend
- name: Build frontend
run: just build-frontend
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
2023-10-20 03:32:02 +00:00
- name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features native-tls,postgres
- name: Run tests
2023-10-20 05:26:00 +00:00
run: cargo test
2023-10-20 04:12:38 +00:00
- name: Build backend
2023-10-20 05:26:00 +00:00
run: cargo build --release
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
2023-10-20 04:12:38 +00:00
- name: Deploy frontend with rsync
run: rsync -avz ./static/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/crawlnicle/crawlnicle/static/
- name: Deploy backend with rsync
run: rsync -avz ./target/release/crawlnicle ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/crawlnicle/crawlnicle/target/release/crawlnicle
2023-10-25 02:42:39 +00:00
# TODO: fancy blue/green deployments
- name: Restart the server
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'sudo /usr/bin/systemctl restart crawlnicle.service'