Skip to content

Commit e77ba7d

Browse files
committed
chore(content): configure Alchemy for Cloudflare deployment
1 parent 27e5a7a commit e77ba7d

File tree

6 files changed

+1641
-70
lines changed

6 files changed

+1641
-70
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Content
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, reopened, synchronize, closed]
8+
9+
concurrency:
10+
group: deploy-content-${{ github.ref }}
11+
12+
env:
13+
STAGE: ${{ github.ref == 'refs/heads/main' && 'prod' || format('pr-{0}', github.event.number) }}
14+
15+
jobs:
16+
deploy:
17+
if: ${{ github.event.action != 'closed' }}
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: pnpm/action-setup@v4
26+
27+
- uses: actions/setup-node@v5
28+
with:
29+
node-version: 22
30+
cache: pnpm
31+
32+
- run: pnpm i
33+
34+
- run: cd apps/content && pnpm alchemy deploy --stage ${{ env.STAGE }}
35+
env:
36+
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}
37+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
38+
PULL_REQUEST: ${{ github.event.number }}
39+
GITHUB_SHA: ${{ github.sha }}
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
cleanup:
43+
runs-on: ubuntu-latest
44+
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
45+
permissions:
46+
contents: read
47+
pull-requests: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- uses: pnpm/action-setup@v4
52+
53+
- uses: actions/setup-node@v5
54+
with:
55+
node-version: 22
56+
cache: pnpm
57+
58+
- run: pnpm i
59+
60+
- run: cd apps/content && pnpm alchemy destroy --stage ${{ env.STAGE }}
61+
env:
62+
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}
63+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

β€Žapps/content/.vitepress/config.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default withMermaid(defineConfig({
2626
],
2727
},
2828
sitemap: {
29-
hostname: 'https://orpc.unnoq.com',
29+
hostname: 'https://orpc.dev',
3030
lastmodDateOnly: true,
3131
},
3232
themeConfig: {

β€Žapps/content/alchemy.run.tsβ€Ž

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable antfu/no-top-level-await */
3+
4+
import process from 'node:process'
5+
import alchemy from 'alchemy'
6+
import { Website } from 'alchemy/cloudflare'
7+
import { GitHubComment } from 'alchemy/github'
8+
import { CloudflareStateStore } from 'alchemy/state'
9+
10+
const app = await alchemy('orpc-content', {
11+
stateStore: scope => new CloudflareStateStore(scope),
12+
})
13+
14+
const content = await Website('content', {
15+
build: {
16+
command: 'pnpm run build',
17+
},
18+
assets: './.vitepress/dist',
19+
...(app.stage === 'prod' && {
20+
domains: ['orpc.dev'],
21+
}),
22+
})
23+
24+
console.log(`βœ… Deployed to: ${content.url}`)
25+
26+
if (process.env.PULL_REQUEST) {
27+
await GitHubComment('preview-comment', {
28+
owner: 'unnoq',
29+
repository: 'orpc',
30+
issueNumber: Number(process.env.PULL_REQUEST),
31+
body: `## πŸš€ Preview Deployed
32+
33+
Your changes have been deployed to a preview environment:
34+
35+
**🌐 Website:** ${content.url}
36+
37+
Built from commit ${process.env.GITHUB_SHA?.slice(0, 7) ?? 'unknown'}
38+
39+
---
40+
<sub>πŸ€– This comment updates automatically with each push.</sub>`,
41+
})
42+
}
43+
44+
await app.finalize()

β€Žapps/content/package.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@tanstack/vue-query": "^5.91.2",
4141
"@types/node": "^22.15.30",
4242
"ai": "5.0.76",
43+
"alchemy": "^0.78.0",
4344
"markdown-it-task-lists": "^2.1.1",
4445
"mermaid": "^11.12.1",
4546
"openai": "^6.9.1",

β€Žapps/content/vercel.jsonβ€Ž

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
Β (0)