-
Notifications
You must be signed in to change notification settings - Fork 799
94 lines (84 loc) · 3.16 KB
/
build.yml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build and Deploy Changes
on:
push:
branches: [main]
paths:
- 'apps/web/**'
- 'apps/extension/**'
- 'apps/cf-ai-backend/**'
pull_request:
branches: [main]
paths:
- 'apps/web/**'
- 'apps/extension/**'
- 'apps/cf-ai-backend/**'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
web_changed: ${{ steps.set_outputs.outputs.web_changed }}
extension_changed: ${{ steps.set_outputs.outputs.extension_changed }}
cf_ai_backend_changed: ${{ steps.set_outputs.outputs.cf_ai_backend_changed }}
steps:
- uses: actions/checkout@v3
- name: Set Outputs
id: set_outputs
run: |
echo "web_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/web/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "extension_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/extension/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "cf_ai_backend_changed=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/cf-ai-backend/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
build-extension:
needs: check-modified-paths
if: needs.prepare.outputs.extension_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/buildextension
build-app:
if: needs.prepare.outputs.web_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install packages
run: bun i
shell: bash
- name: Build app
run: bun run pages:build
working-directory: apps/web
shell: bash
env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
BACKEND_SECURITY_KEY: ${{ secrets.BACKEND_SECURITY_KEY }}
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
directory: apps/web/.vercel/output/static
branch: main
deploy-cf-worker:
if: needs.prepare.outputs.cf_ai_backend_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Deploy to Cloudflare Workers
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
script: wrangler publish
working-directory: apps/cf-ai-backend
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SECURITY_KEY: ${{ secrets.BACKEND_SECURITY_KEY }}