diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 179c983..0ff655a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,56 +1,60 @@ -name: Deploy to Shuttle +name: Build and Deploy to shuttle.rs on: + push: + branches: + - master pull_request: - branches: [master] - types: [closed] + branches: + - master jobs: - deploy: - if: github.event.pull_request.merged == true + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - # Install wasm32-unknown-unknown target - - name: Install wasm32-unknown-unknown target - run: rustup target add wasm32-unknown-unknown - - # Build frontend - - name: Install Node.js - uses: actions/setup-node@v3 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v4 with: - node-version: 16 - - name: Install Tailwind CSS - run: npm install -D tailwindcss - working-directory: ./frontend - - name: Install trunk - 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 + path: | + ~/.cargo + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-df + - name: Install Rust uses: actions-rs/toolchain@v1 with: + profile: minimal toolchain: stable - override: true - - name: Deploy to shuttle.rs - uses: shuttle-hq/deploy-action@main - with: - allow-dirty: "true" - deploy-key: ${{ secrets.SHUTTLE_TOKEN }} - # run: cargo install --locked cargo-shuttle - # - name: Deploy to Shuttle - # env: - # SHUTTLE_TOKEN: ${{ secrets.SHUTTLE_TOKEN }} - # run: | - # cargo shuttle login --api-key $SHUTTLE_TOKEN - # cargo shuttle deploy + + - name: Install Trunk + run: cargo install trunk + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Tailwind CSS + run: npm install -g tailwindcss + + - 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 }}