diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 358d7de..8061326 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -10,10 +10,43 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - run: actions/checkout@v3 + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Install Node.js dependencies + run: npm ci + + - name: Run ESLint + run: npm run lint + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + markdown_backend/target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Check Rust code + working-directory: markdown_backend + run: cargo check - name: Install Docker - run: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v2 - name: Build Docker image run: docker build -t markdownblog . @@ -22,7 +55,10 @@ jobs: run: docker save markdownblog -o markdownblog-image.tar - name: Upload Docker image artifact - run: actions/upload-artifact@v3 --name markdownblog-docker-image --path markdownblog-image.tar + uses: actions/upload-artifact@v3 + with: + name: markdownblog-docker-image + path: markdownblog-image.tar - name: Push Docker image - run: docker push 10.0.0.13:3002/rattatwinko/markdownblog:latest + run: docker push localhost:3002/rattatwinko/markdownblog:latest diff --git a/docker.sh b/docker.sh index a75ae64..bbb1823 100755 --- a/docker.sh +++ b/docker.sh @@ -45,4 +45,4 @@ if ! docker ps | grep -q $CONTAINER_NAME; then fi echo "Deployment complete!" -echo "App should be available at http://localhost:$PORT" +echo "App should be available at http://localhost:$PORT" \ No newline at end of file diff --git a/markdown_backend/steps.yml b/markdown_backend/steps.yml deleted file mode 100644 index 0ab3dcf..0000000 --- a/markdown_backend/steps.yml +++ /dev/null @@ -1,101 +0,0 @@ -project_setup: - description: Setup Rust and Next.js to compile Rust to WASM for web use - prerequisites: - - Node.js >= 18 - - Rust >= 1.70 - - wasm-pack installed (`cargo install wasm-pack`) - - Next.js app created (`npx create-next-app@latest`) - - Optional: TypeScript enabled - steps: - - name: Create Rust crate - run: | - mkdir rust-wasm - cd rust-wasm - cargo new --lib wasm_core - cd wasm_core - - - name: Add wasm dependencies to Cargo.toml - file: rust-wasm/wasm_core/Cargo.toml - append: - dependencies: - wasm-bindgen: "0.2" - [lib]: - crate-type: ["cdylib"] - [package.metadata.wasm-pack.profile.release] - wasm-opt: true - - - name: Write simple Rust function - file: rust-wasm/wasm_core/src/lib.rs - content: | - use wasm_bindgen::prelude::*; - - #[wasm_bindgen] - pub fn greet(name: &str) -> String { - format!("Hello, {}!", name) - } - - - name: Build WASM module with wasm-pack - run: | - cd rust-wasm/wasm_core - wasm-pack build --target web --out-dir ../pkg - - nextjs_setup: - description: Integrate the WASM output into a Next.js app - steps: - - name: Move compiled WASM pkg to Next.js public or static - run: | - # Assuming your Next.js app is in ../my-app - mkdir -p ../my-app/public/wasm - cp -r ../rust-wasm/pkg/* ../my-app/public/wasm/ - - - name: Import and initialize WASM in React - file: my-app/app/page.tsx - content: | - 'use client'; - import { useEffect, useState } from "react"; - - export default function Home() { - const [output, setOutput] = useState(""); - - useEffect(() => { - (async () => { - const wasm = await import("../../public/wasm/wasm_core.js"); - await wasm.default(); // init - const result = wasm.greet("Next.js + Rust"); - setOutput(result); - })(); - }, []); - - return