Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
GITHUB_CALLBACK_URL=https://your-domain.com/api/auth/callback

JWT_SECRET=your_super_secret_random_string_at_least_32_chars
89 changes: 47 additions & 42 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
name: Deploy to Cloudflare Pages
name: Deploy to Cloudflare Workers

on:
pull_request:
types: [closed]
branches: [main]
pull_request:
types: [closed]
branches: [main]

jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
deployments: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build
env:
NODE_VERSION: '22'

- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=4byte-dev
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '3'
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
environment: production

permissions:
contents: read
deployments: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Install Wrangler
run: pnpm add -D wrangler@4

- name: Build Astro
run: |
pnpm generate:data
pnpm generate:og
pnpm build

- name: Deploy Production Worker
run: |
cd dist/server
npx wrangler deploy --config wrangler.json --name 4byte-dev
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
114 changes: 56 additions & 58 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
name: Preview Deployment

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
branches: [main]

jobs:
deploy-preview:
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
deployments: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Generate and Build
run: |
pnpm generate:data
pnpm generate:og
pnpm build
env:
NODE_VERSION: '22'

- name: Deploy Preview to Cloudflare Pages
id: preview
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=4byte-dev --branch=${{ github.head_ref }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '3'

- name: Add or Update PR Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: preview-url
message: |
**Preview Deployment is Ready!**

You can test the updates in this PR in a live environment by clicking the link below:
[View Preview](${{ steps.preview.outputs.deployment-url }})

*(This environment is specific to this PR and does not affect the `main` branch. The content at this link will update automatically when you push new commits to the PR.)*
deploy-preview:
runs-on: ubuntu-latest
environment: production

permissions:
contents: read
deployments: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Install Wrangler
run: pnpm add -D wrangler@4

- name: Build Astro
run: |
pnpm generate:data
pnpm generate:og
pnpm build

- name: Deploy Preview Worker
id: deploy
run: |
cd dist/server
npx wrangler deploy --config wrangler.json --name 4byte-dev-pr-${{ github.event.pull_request.number }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Add PR Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: preview-url
message: |
**Preview Deployment is Ready!**

https://4byte-dev-pr-${{ github.event.pull_request.number }}.4byte-development.workers.dev
5 changes: 5 additions & 0 deletions .wrangler/deploy/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"configPath": "../../dist/server/wrangler.json",
"auxiliaryWorkers": [],
"prerenderWorkerConfigPath": "../../dist/server/.prerender/wrangler.json"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import partytown from '@astrojs/partytown'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'
import mdx from '@astrojs/mdx'
import cloudflare from '@astrojs/cloudflare'

export default defineConfig({
site: 'https://4byte.dev',
output: 'static',
adapter: cloudflare({
imageService: 'cloudflare',
}),
integrations: [
UnoCSS(),
mdx(),
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"check:slugs": "node scripts/check-slugs.mjs"
},
"dependencies": {
"@astrojs/cloudflare": "^13.1.7",
"@astrojs/mdx": "^5.0.2",
"@astrojs/partytown": "^2.1.5",
"@astrojs/sitemap": "^3.7.1",
Expand All @@ -29,6 +30,7 @@
"astro-icon": "^1.1.5",
"d3": "^7.9.0",
"gray-matter": "^4.0.3",
"jose": "^6.2.2",
"katex": "^0.16.40",
"rehype-katex": "^7.0.1",
"remark-math": "^6.0.0",
Expand Down
Loading
Loading