Skip to content

safeos(docs): note ui+api run together and document Ollama setup #61

safeos(docs): note ui+api run together and document Ollama setup

safeos(docs): note ui+api run together and document Ollama setup #61

Workflow file for this run

# SafeOS Guardian - CI/CD Pipeline
# Runs on push to main/master and pull requests
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
# =============================================================================
# Lint & Type Check
# =============================================================================
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Type check
run: npx tsc --noEmit || echo "Type errors found (non-blocking)"
- name: Lint
run: npm run lint || echo "No lint script"
# =============================================================================
# Unit Tests
# =============================================================================
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Run tests with coverage
run: npm test -- --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
flags: safeos
fail_ci_if_error: false
# =============================================================================
# Build Backend
# =============================================================================
build-backend:
name: Build Backend
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Build
run: npx tsc -p tsconfig.json
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: backend-dist
path: dist
retention-days: 7
# =============================================================================
# Build Frontend
# =============================================================================
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
needs: [lint]
defaults:
run:
working-directory: apps/guardian-ui
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Build
run: npm run build
env:
NEXT_PUBLIC_API_URL: https://api.safeos.dev
NEXT_PUBLIC_WS_URL: wss://api.safeos.dev
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: apps/guardian-ui/.next
retention-days: 7
# =============================================================================
# Docker Build
# =============================================================================
docker:
name: Docker Build
runs-on: ubuntu-latest
needs: [build-backend, build-frontend]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push API
uses: docker/build-push-action@v5
with:
context: .
target: backend
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/safeos-api:latest
ghcr.io/${{ github.repository_owner }}/safeos-api:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push UI
uses: docker/build-push-action@v5
with:
context: .
target: frontend
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/safeos-ui:latest
ghcr.io/${{ github.repository_owner }}/safeos-ui:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# =============================================================================
# Deploy to GitHub Pages (Frontend Only)
# =============================================================================
deploy-pages:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: [build-frontend]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
run: npm install --legacy-peer-deps
working-directory: apps/guardian-ui
- name: Build static export
run: npm run build
working-directory: apps/guardian-ui
env:
NEXT_PUBLIC_API_URL: https://api.safeos.dev
NEXT_PUBLIC_WS_URL: wss://api.safeos.dev
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: apps/guardian-ui/out
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4