-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.97 KB
/
Copy pathdeploy.yml
File metadata and controls
53 lines (50 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: deploy
# Deploys the showcase to Cloudflare Pages on push to main — but only once the
# Cloudflare secrets are present, so the workflow stays green until you add them.
# Required repo secrets:
# CLOUDFLARE_API_TOKEN - token with "Cloudflare Pages: Edit" on the plot.ws account
# CLOUDFLARE_ACCOUNT_ID - the plot.ws account id
# VITE_PLOT_APP_KEY - publishable demo app key (pl_pub_live_...) so the games connect
# Optional:
# VITE_PLOT_API_URL - override the API origin (defaults to https://api.plot.ws)
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check for Cloudflare credentials
id: gate
env:
TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
ACCT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
if [ -n "$TOKEN" ] && [ -n "$ACCT" ]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
else
echo "ready=false" >> "$GITHUB_OUTPUT"
echo "::notice::Cloudflare secrets not set — skipping deploy. Add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID to enable."
fi
- uses: actions/checkout@v4
if: steps.gate.outputs.ready == 'true'
- uses: actions/setup-node@v4
if: steps.gate.outputs.ready == 'true'
with:
node-version: 20
- if: steps.gate.outputs.ready == 'true'
run: npm ci || npm install
- name: Build
if: steps.gate.outputs.ready == 'true'
env:
VITE_PLOT_APP_KEY: ${{ secrets.VITE_PLOT_APP_KEY }}
VITE_PLOT_API_URL: ${{ secrets.VITE_PLOT_API_URL }}
run: npm run build
- name: Deploy to Cloudflare Pages
if: steps.gate.outputs.ready == 'true'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=plot-showcase --branch=main