feat: improve gh action

This commit is contained in:
itsscb 2024-08-23 14:57:44 +02:00 committed by GitHub
parent 8531520665
commit 04a36990cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,56 +1,60 @@
name: Deploy to Shuttle name: Build and Deploy to shuttle.rs
on: on:
push:
branches:
- master
pull_request: pull_request:
branches: [master] branches:
types: [closed] - master
jobs: jobs:
deploy: build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
uses: actions/checkout@v4
# Install wasm32-unknown-unknown target
- name: Install wasm32-unknown-unknown target - name: Cache dependencies
run: rustup target add wasm32-unknown-unknown uses: actions/cache@v4
# Build frontend
- name: Install Node.js
uses: actions/setup-node@v3
with: with:
node-version: 16 path: |
- name: Install Tailwind CSS ~/.cargo
run: npm install -D tailwindcss target/
working-directory: ./frontend key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install trunk restore-keys: ${{ runner.os }}-cargo-df
run: cargo install trunk
- name: Rename Trunk.toml
run: mv Trunk.toml Trunk.bkp
working-directory: ./frontend
- name: Build frontend
run: trunk build --release
working-directory: ./frontend
- name: Rename Trunk.toml back
run: mv Trunk.bkp Trunk.toml
working-directory: ./frontend
# Deploy backend
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
profile: minimal
toolchain: stable toolchain: stable
override: true
- name: Deploy to shuttle.rs - name: Install Trunk
uses: shuttle-hq/deploy-action@main run: cargo install trunk
with:
allow-dirty: "true" - name: Install Node.js
deploy-key: ${{ secrets.SHUTTLE_TOKEN }} uses: actions/setup-node@v4
# run: cargo install --locked cargo-shuttle with:
# - name: Deploy to Shuttle node-version: 20
# env:
# SHUTTLE_TOKEN: ${{ secrets.SHUTTLE_TOKEN }} - name: Install Tailwind CSS
# run: | run: npm install -g tailwindcss
# cargo shuttle login --api-key $SHUTTLE_TOKEN
# cargo shuttle deploy - name: Build Frontend
run: |
trunk build --release
- name: Build and Test backend
run: |
cargo build --verbose --release
cargo test --verbose
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: shuttle-hq/deploy-action@main
with:
deploy-key: ${{ secrets.SHUTTLE_API_KEY }}