-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 1.88 KB
/
Copy pathdeploy-frontend.yml
File metadata and controls
64 lines (55 loc) · 1.88 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
54
55
56
57
58
59
60
61
62
63
64
name: Deploy Frontend
on:
pull_request:
paths:
- "frontend/**"
- ".github/workflows/deploy-frontend.yml"
push:
branches:
- main
paths:
- "frontend/**"
- ".github/workflows/deploy-frontend.yml"
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
deploy:
runs-on: ubuntu-latest
env:
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL }}
HAS_CLOUDFLARE_CONFIG: ${{ secrets.CLOUDFLARE_API_TOKEN != '' && secrets.CLOUDFLARE_ACCOUNT_ID != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Skip Cloudflare deploy
if: github.event_name != 'push' || github.ref != 'refs/heads/main' || env.HAS_CLOUDFLARE_CONFIG != 'true'
run: |
{
echo "### Cloudflare deploy skipped"
echo
echo "The frontend build passed. Deployment only runs for pushes to main when both GitHub secrets are configured:"
echo
echo "- CLOUDFLARE_API_TOKEN"
echo "- CLOUDFLARE_ACCOUNT_ID"
} >> "$GITHUB_STEP_SUMMARY"
- name: Deploy to Cloudflare Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.HAS_CLOUDFLARE_CONFIG == 'true'
working-directory: frontend
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: npx wrangler pages deploy dist --project-name docuflow-ocr --branch main