Folo/.github/workflows/deploy-cloudflare.yml

135 lines
4.8 KiB
YAML

on:
push:
branches: [main, dev]
workflow_dispatch:
inputs:
landing_source_ref:
description: Branch, tag, or commit SHA to deploy for landing production
required: true
default: dev
type: string
confirm_landing_prod_deploy:
description: Deploy landing to production (folo.is)
required: true
default: false
type: boolean
name: ☁️ Deploy to Cloudflare Workers
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && format('manual-landing-prod-{0}', inputs.landing_source_ref) || github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
env:
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }}
VITE_FIREBASE_CONFIG: ${{ vars.VITE_FIREBASE_CONFIG }}
strategy:
matrix:
node-version: [lts/*]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
lfs: true
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.landing_source_ref || github.ref }}
- name: Checkout LFS objects
run: git lfs checkout
- name: Cache turbo build setup
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build desktop web (SPA)
if: github.event_name == 'push'
working-directory: apps/desktop
env:
VITE_WEB_URL: ${{ github.ref == 'refs/heads/dev' && 'https://dev.folo.is' || 'https://app.folo.is' }}
VITE_API_URL: ${{ github.ref == 'refs/heads/dev' && 'https://api.dev.folo.is' || 'https://api.folo.is' }}
run: pnpm run build:web
- name: Build SSR Worker
if: github.event_name == 'push'
working-directory: apps/ssr
run: pnpm run build:worker
- name: Copy WASM file
if: github.event_name == 'push'
run: cp node_modules/@resvg/resvg-wasm/index_bg.wasm apps/ssr/dist/worker/resvg.wasm
- name: Build Landing Worker
run: pnpm exec turbo run @follow/landing#cf:build
- name: Deploy SSR Worker to Cloudflare (dev)
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/ssr
command: deploy --env dev
- name: Deploy desktop web to Cloudflare (dev)
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/desktop
command: deploy --env dev
- name: Deploy Landing to Cloudflare (dev)
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/landing
command: deploy --env dev --name landing-next-dev --routes landing.dev.folo.is/*
- name: Deploy SSR Worker to Cloudflare (prod)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/ssr
command: 'deploy --env=""'
- name: Deploy desktop web to Cloudflare (prod)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/desktop
command: 'deploy --env=""'
- name: Deploy Landing to Cloudflare (prod)
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.confirm_landing_prod_deploy)
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/landing
command: deploy