every.channel/.forgejo/workflows/deploy-cloudflare.yml
2026-02-16 00:39:26 -05:00

54 lines
1.7 KiB
YAML

name: deploy-cloudflare
on:
push:
branches: [main]
workflow_dispatch: {}
concurrency:
group: cloudflare-deploy-${{ forgejo.ref }}
cancel-in-progress: true
jobs:
deploy:
# Use Codeberg global hosted runners by label.
# Available labels in this repo are: codeberg-tiny, codeberg-small, codeberg-medium.
runs-on: codeberg-medium
steps:
- name: Deploy website + worker
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CODEBERG_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
run: |
set -euo pipefail
if [[ ! -f "./scripts/deploy-workers.sh" ]]; then
if [[ -z "${CODEBERG_TOKEN:-}" ]]; then
echo "error: workspace missing repo files and CODEBERG_TOKEN is not set"
exit 2
fi
git clone "https://every-channel:${CODEBERG_TOKEN}@codeberg.org/every-channel/every.channel.git" .repo
cd .repo
fi
if ! command -v cargo >/dev/null 2>&1; then
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
. "$HOME/.cargo/env"
elif [[ -f "$HOME/.cargo/env" ]]; then
. "$HOME/.cargo/env"
fi
rustup target add wasm32-unknown-unknown
if ! command -v trunk >/dev/null 2>&1; then
cargo install trunk --locked
fi
if ! command -v npm >/dev/null 2>&1; then
echo "error: npm is not available on this runner"
exit 2
fi
cd apps/tauri/ui
trunk build --release --public-url /
cd ../../../deploy/cloudflare-worker
npm ci
npx wrangler deploy