oopsie lmao #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
- name: Install wasm toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
target: wasm32-unknown-unknown | |
- name: Install Trunk | |
uses: jetli/[email protected] | |
with: | |
version: 'latest' | |
- name: Install wasm-opt | |
run: "curl -L -o binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz && tar -xzvf ./binaryen.tar.gz" | |
- name: Build backend | |
run: cargo build --profile production --bin backend | |
- name: Build frontend | |
run: "cd frontend && trunk build --release" | |
- name: Optimise wasm | |
run: "cd frontend/dist && ../../binaryen-version_116/bin/wasm-opt -Oz -o opt.wasm $(ls frontend*.wasm) && mv ./opt.wasm $(ls frontend*.wasm)" | |
- name: Minify js | |
uses: nizarmah/[email protected] | |
with: | |
overwrite: true | |
directory: frontend/dist | |
js_engine: uglify-js | |
- name: Stop currently-running backend | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: | | |
sudo /usr/bin/systemctl stop itsjunetime.service | |
rm /home/junkie/server_files/frontend* 2>/dev/null || : | |
- name: SCP files | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
source: "target/production/backend,frontend/dist/*" | |
target: /home/junkie/server_files/ | |
strip_components: 2 | |
overwrite: true | |
- name: Restart server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: | | |
sudo /usr/bin/systemctl daemon-reload | |
sudo /usr/bin/systemctl start itsjunetime.service | |
sudo /usr/sbin/nginx -s reload |