2023-10-20 02:53:09 +00:00
|
|
|
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:12:31 +00:00
|
|
|
|
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
|
|
|
|
|
2023-10-20 02:53:09 +00:00
|
|
|
- name: Run tests
|
|
|
|
run: cargo test --verbose
|
2023-10-20 03:12:31 +00:00
|
|
|
|
2023-10-20 04:12:38 +00:00
|
|
|
- name: Build backend
|
2023-10-20 03:12:31 +00:00
|
|
|
run: cargo build --release --verbose
|
|
|
|
|
2023-10-20 02:53:09 +00:00
|
|
|
- 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'
|
2023-10-20 03:12:31 +00:00
|
|
|
|
2023-10-20 02:53:09 +00:00
|
|
|
- name: Adding Known Hosts
|
|
|
|
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
|
2023-10-20 03:12:31 +00:00
|
|
|
|
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
|
2023-10-20 02:53:09 +00:00
|
|
|
run: rsync -avz ./target/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/crawlnicle/crawlnicle/target/
|