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
118 changes: 118 additions & 0 deletions .github/workflows/deploy-landing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: deploy-landing

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- src/landing.ts
- scripts/build-landing.ts
- package.json
- pnpm-lock.yaml
- .github/workflows/deploy-landing.yml
push:
branches:
- main
paths:
- src/landing.ts
- scripts/build-landing.ts
- package.json
- pnpm-lock.yaml
- .github/workflows/deploy-landing.yml

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

concurrency:
group: deploy-landing-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
deploy-preview:
name: Preview
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.event.pull_request.head.repo.fork == false && github.actor != 'dependabot[bot]' }}
runs-on: [arc-runner-set]
timeout-minutes: 10

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

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

- name: Enable Corepack
run: corepack enable

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

- name: Build landing
run: pnpm build:landing

- name: Deploy preview to Vercel
id: deploy
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
set -euo pipefail
url=$(npx vercel@51 deploy ./dist/landing --yes --token="$VERCEL_TOKEN")
echo "url=$url" >> "$GITHUB_OUTPUT"

- name: Comment preview URL on PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PREVIEW_URL: ${{ steps.deploy.outputs.url }}
run: |
set -euo pipefail
marker="<!-- landing-preview-url -->"
body=$(printf '%s\n**Landing preview:** %s\n\nBuilt from %s' "$marker" "$PREVIEW_URL" "${GITHUB_SHA:0:7}")
existing_id=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
--jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -1)
if [ -n "$existing_id" ]; then
gh api "repos/${{ github.repository }}/issues/comments/${existing_id}" \
--method PATCH --field body="$body"
else
gh pr comment "$PR_NUMBER" --body "$body"
fi

deploy-production:
name: Production
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: [arc-runner-set]
timeout-minutes: 10
environment:
name: production-landing
url: https://tack.taiko.xyz

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

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

- name: Enable Corepack
run: corepack enable

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

- name: Build landing
run: pnpm build:landing

- name: Deploy production to Vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
set -euo pipefail
npx vercel@51 deploy ./dist/landing --prod --yes --token="$VERCEL_TOKEN"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ node_modules
# Build output
dist

# Vercel
.vercel

# Test coverage
coverage

Expand Down Expand Up @@ -33,3 +36,4 @@ backups/
# Logs
*.log
.claude/
.gstack/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"test:watch": "vitest",
"typecheck": "tsc --noEmit",
"release:notes": "node scripts/extract-changelog-section.mjs",
"smoke:x402": "tsx src/scripts/x402-smoke.ts"
"smoke:x402": "tsx src/scripts/x402-smoke.ts",
"build:landing": "tsx scripts/build-landing.ts"
},
"dependencies": {
"@hono/node-server": "^1.13.8",
Expand Down
13 changes: 13 additions & 0 deletions scripts/build-landing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

import { landingPageHtml } from '../src/landing';

const outDir = resolve(process.cwd(), 'dist', 'landing');
const outFile = resolve(outDir, 'index.html');

rmSync(outDir, { recursive: true, force: true });
mkdirSync(outDir, { recursive: true });
writeFileSync(outFile, landingPageHtml(), 'utf8');

console.log(`Wrote ${outFile}`);
3 changes: 1 addition & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ export function createApp(services: AppServices): Hono<AppEnv> {
}));

app.get('/', (c) => {
const origin = new URL(c.req.url).origin;
return c.html(landingPageHtml(origin));
return c.html(landingPageHtml());
});

app.use('*', async (c, next) => {
Expand Down
Loading