Skip to content

Commit 9cde8ed

Browse files
committed
Fix CI workflows
1 parent 605a7cc commit 9cde8ed

9 files changed

Lines changed: 142 additions & 51 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Setup
2+
description: Setup Node.js, pnpm, and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup pnpm
8+
uses: pnpm/action-setup@v4
9+
10+
- name: Setup Node
11+
uses: actions/setup-node@v4
12+
with:
13+
node-version: "22"
14+
cache: "pnpm"
15+
16+
- name: Install Dependencies
17+
shell: bash
18+
run: pnpm install --frozen-lockfile

.github/workflows/ci.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,8 @@ jobs:
1414
- name: Checkout
1515
uses: actions/checkout@v4
1616

17-
- name: Setup pnpm
18-
uses: pnpm/action-setup@v4
19-
20-
- name: Setup Node
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: "22"
24-
cache: "pnpm"
25-
26-
- name: Install Dependencies
27-
run: pnpm install --frozen-lockfile
17+
- name: Setup
18+
uses: ./.github/actions/setup
2819

2920
- name: Setup Environment
3021
run: cp .env.dist .env
@@ -49,13 +40,8 @@ jobs:
4940
- name: Checkout
5041
uses: actions/checkout@v4
5142

52-
- name: Setup pnpm
53-
uses: pnpm/action-setup@v4
54-
55-
- name: Setup Node
56-
uses: actions/setup-node@v4
57-
with:
58-
node-version: "22"
43+
- name: Setup
44+
uses: ./.github/actions/setup
5945

6046
- name: Download Build Artifacts
6147
uses: actions/download-artifact@v4
@@ -73,13 +59,8 @@ jobs:
7359
- name: Checkout
7460
uses: actions/checkout@v4
7561

76-
- name: Setup pnpm
77-
uses: pnpm/action-setup@v4
78-
79-
- name: Setup Node
80-
uses: actions/setup-node@v4
81-
with:
82-
node-version: "22"
62+
- name: Setup
63+
uses: ./.github/actions/setup
8364

8465
- name: Download Build Artifacts
8566
uses: actions/download-artifact@v4
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy Production
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: "Branch or tag to deploy (leave empty for default branch)"
8+
required: false
9+
type: string
10+
default: ""
11+
12+
jobs:
13+
deploy:
14+
uses: ./.github/workflows/wrangler-deploy.yml
15+
with:
16+
environment: production
17+
site_url: https://johnhooks.io
18+
ref: ${{ inputs.ref }}
19+
secrets:
20+
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
21+
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy Staging
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: "Branch or tag to deploy (leave empty for default branch)"
8+
required: false
9+
type: string
10+
default: ""
11+
12+
jobs:
13+
deploy:
14+
uses: ./.github/workflows/wrangler-deploy.yml
15+
with:
16+
environment: staging
17+
site_url: https://website-staging.johnhooks.workers.dev
18+
ref: ${{ inputs.ref }}
19+
secrets:
20+
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
21+
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Reusable Workflow - Wrangler Deploy
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
description: Environment to deploy (production or staging)
10+
site_url:
11+
required: true
12+
type: string
13+
description: Site URL for build
14+
ref:
15+
required: false
16+
type: string
17+
description: Git ref to deploy
18+
default: ""
19+
secrets:
20+
cloudflare_api_token:
21+
required: true
22+
cloudflare_account_id:
23+
required: true
24+
25+
jobs:
26+
deploy:
27+
runs-on: ubuntu-latest
28+
environment: ${{ inputs.environment }}
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.ref || github.ref }}
35+
36+
- name: Setup
37+
uses: ./.github/actions/setup
38+
39+
- name: Build
40+
run: pnpm build
41+
env:
42+
SITE_URL: ${{ inputs.site_url }}
43+
44+
- name: Deploy to Cloudflare
45+
run: pnpm wrangler deploy --env ${{ inputs.environment }}
46+
env:
47+
CLOUDFLARE_API_TOKEN: ${{ secrets.cloudflare_api_token }}
48+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.cloudflare_account_id }}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

docs/plans/sitemap.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ${allUrls
4343
.map(
4444
(url) => ` <url>
4545
<loc>${SITE_URL}${url}</loc>
46-
</url>`
46+
</url>`,
4747
)
4848
.join("\n")}
4949
</urlset>`;
@@ -71,6 +71,7 @@ ${allUrls
7171
## Verification
7272

7373
After implementation:
74+
7475
1. Run `pnpm build` and check `.svelte-kit/cloudflare/sitemap.xml` exists
7576
2. Validate XML structure at https://www.xml-sitemaps.com/validate-xml-sitemap.html
7677
3. Submit to Google Search Console when ready

src/app.html

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<!doctype html>
22
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
6+
<meta name="viewport" content="width=device-width" />
7+
<script>
8+
// Initialize the agent on page load.
9+
const fpPromise =
10+
import("https://fpjscdn.net/v3/h7Y33UUCeemER3W7dVpx").then(
11+
(FingerprintJS) => FingerprintJS.load(),
12+
);
313

4-
<head>
5-
<meta charset="utf-8" />
6-
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
7-
<meta name="viewport" content="width=device-width" />
8-
<script>
9-
// Initialize the agent on page load.
10-
const fpPromise = import('https://fpjscdn.net/v3/h7Y33UUCeemER3W7dVpx')
11-
.then(FingerprintJS => FingerprintJS.load())
12-
13-
// Get the visitorId when you need it.
14-
fpPromise
15-
.then(fp => fp.get())
16-
.then(result => {
17-
const visitorId = result.visitorId
18-
console.log(visitorId)
19-
})
20-
</script>
21-
%sveltekit.head%
22-
</head>
23-
24-
<body class="bg-gray-50">
25-
<div>%sveltekit.body%</div>
26-
</body>
14+
// Get the visitorId when you need it.
15+
fpPromise
16+
.then((fp) => fp.get())
17+
.then((result) => {
18+
const visitorId = result.visitorId;
19+
console.log(visitorId);
20+
});
21+
</script>
22+
%sveltekit.head%
23+
</head>
2724

25+
<body class="bg-gray-50">
26+
<div>%sveltekit.body%</div>
27+
</body>
2828
</html>

src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</div>
7777

7878
<ul class="mt-6 pt-10 grid gap-16 lg:grid-cols-2 lg:gap-x-5 lg:gap-y-12">
79-
{#each data.posts as post}
79+
{#each data.posts as post (post.slug)}
8080
<li>
8181
<!-- <p class="text-sm text-gray-500">
8282
<time datetime="{formatDate(post.publishedOn, "yyyy-MM-dd")}">
@@ -110,7 +110,7 @@
110110
</div>
111111

112112
<ul class="mt-6 pt-10 grid gap-16 lg:grid-cols-2 lg:gap-x-5 lg:gap-y-12">
113-
{#each data.projects as project}
113+
{#each data.projects as project (project.slug)}
114114
<li>
115115
<a href="/projects/{project.slug}" class="mt-2 block">
116116
<p class="text-xl font-semibold text-gray-900">

0 commit comments

Comments
 (0)