2024-08-28 20:46:14 +02:00

93 lines
2.3 KiB
YAML

on:
push:
branches:
- master
permissions:
contents: write
issues: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/
~/.cargo/bin/
~/.cache/trunk/
target/
node_modules/
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-wordl
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: add rust target wasm32-unknown-unknown
run: rustup target add wasm32-unknown-unknown
- name: install trunk
run: cargo install trunk
- name: install node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: install tailwindcss
run: npm install -g tailwindcss
- name: build frontend
working-directory: ./frontend/
run: |
trunk build --release
- name: commit frontend release build
run: |
git config --global user.name "GitHub Action"
git config --global user.email "actions@github.com"
git add frontend/dist -f
git diff --staged --quiet || (git commit -m "release: frontend build ${{ github.sha }} [skip ci]" && git push)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: upload frontend artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-artifacts
path: ./frontend/dist
- name: run tests
run: |
cargo test --verbose
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: checkout
uses: actions/checkout@v4
- name: download frontend artifacts
uses: actions/download-artifact@v4
with:
name: frontend-artifacts
- name: display structure of downloaded files
run: ls -R
working-directory: ./frontend/dist
- uses: shuttle-hq/deploy-action@main
with:
deploy-key: ${{ secrets.SHUTTLE_API_KEY }}
working-directory: .