Skip to content

Commit 521c823

Browse files
committed
feat: add wrangler
1 parent f8d9c7d commit 521c823

File tree

3 files changed

+29
-49
lines changed

3 files changed

+29
-49
lines changed

.github/workflows/astro.yml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,48 @@
1-
# Sample workflow for building and deploying an Astro site to GitHub Pages
2-
#
3-
# To get started with Astro see: https://docs.astro.build/en/getting-started/
4-
#
5-
name: Deploy Astro site to Pages
1+
name: Deploy Astro site to Cloudflare Workers
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
10-
branches: ["master"]
11-
12-
# Allows you to run this workflow manually from the Actions tab
5+
branches: ['master']
136
workflow_dispatch:
147

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
168
permissions:
179
contents: read
1810
deployments: write
19-
id-token: write
2011

21-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2312
concurrency:
24-
group: "pages"
13+
group: 'deploy'
2514
cancel-in-progress: false
2615

27-
env:
28-
BUILD_PATH: "." # default value when not using subfolders
29-
# BUILD_PATH: subfolder
30-
3116
jobs:
32-
build:
33-
name: Build
17+
deploy:
18+
name: Build & Deploy
3419
runs-on: ubuntu-latest
3520
steps:
3621
- name: Checkout
3722
uses: actions/checkout@v4
38-
- name: Detect package manager
39-
id: detect-package-manager
40-
run: |
41-
if [ -f "${{ github.workspace }}/package.json" ]; then
42-
echo "manager=pnpm" >> $GITHUB_OUTPUT
43-
echo "command=i --frozen-lockfile" >> $GITHUB_OUTPUT
44-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
45-
echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT
46-
exit 0
47-
else
48-
echo "Unable to determine package manager"
49-
exit 1
50-
fi
23+
5124
- name: Setup pnpm
52-
uses: pnpm/action-setup@v4.0.0
25+
uses: pnpm/action-setup@v4
5326
with:
54-
version: "9.7.0"
27+
version: '9'
28+
5529
- name: Setup Node
5630
uses: actions/setup-node@v4
5731
with:
58-
node-version: "20.15.1"
59-
cache: ${{ steps.detect-package-manager.outputs.manager }}
60-
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
32+
node-version: '20'
33+
cache: pnpm
34+
6135
- name: Install dependencies
62-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
63-
working-directory: ${{ env.BUILD_PATH }}
36+
run: pnpm i --frozen-lockfile
37+
6438
- name: Install noto-cjk
6539
run: sudo apt-get install -y fonts-noto-cjk
40+
6641
- name: Build with Astro
67-
run: |
68-
${{ steps.detect-package-manager.outputs.runner }} astro build
69-
working-directory: ${{ env.BUILD_PATH }}
70-
- name: Publish
71-
uses: cloudflare/pages-action@v1.5.0
42+
run: pnpm astro build
43+
44+
- name: Deploy to Cloudflare Workers
45+
uses: cloudflare/wrangler-action@v3
7246
with:
7347
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7448
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
75-
projectName: "blog" # e.g. 'my-project'
76-
directory: "dist" # e.g. 'dist'
77-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

src/content/typst_tutor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 简单的 Typst 教程
33
pubDatetime: 2023-12-21T08:20:00Z
4-
description: 使用typst ,与\反斜杠说再见
4+
description: 使用typst,与\反斜杠说再见
55
author: Parsifal
66
tags:
77
- computer

wrangler.jsonc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "node_modules/wrangler/config-schema.json",
3+
"name": "blog",
4+
"compatibility_date": "2026-02-13",
5+
"assets": {
6+
"directory": "./dist",
7+
"not_found_handling": "404-page",
8+
},
9+
}

0 commit comments

Comments
 (0)