|
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 |
6 | 2 |
|
7 | 3 | on: |
8 | | - # Runs on pushes targeting the default branch |
9 | 4 | push: |
10 | | - branches: ["master"] |
11 | | - |
12 | | - # Allows you to run this workflow manually from the Actions tab |
| 5 | + branches: ['master'] |
13 | 6 | workflow_dispatch: |
14 | 7 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 | 8 | permissions: |
17 | 9 | contents: read |
18 | 10 | deployments: write |
19 | | - id-token: write |
20 | 11 |
|
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. |
23 | 12 | concurrency: |
24 | | - group: "pages" |
| 13 | + group: 'deploy' |
25 | 14 | cancel-in-progress: false |
26 | 15 |
|
27 | | -env: |
28 | | - BUILD_PATH: "." # default value when not using subfolders |
29 | | -# BUILD_PATH: subfolder |
30 | | - |
31 | 16 | jobs: |
32 | | - build: |
33 | | - name: Build |
| 17 | + deploy: |
| 18 | + name: Build & Deploy |
34 | 19 | runs-on: ubuntu-latest |
35 | 20 | steps: |
36 | 21 | - name: Checkout |
37 | 22 | 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 | + |
51 | 24 | - name: Setup pnpm |
52 | | - uses: pnpm/action-setup@v4.0.0 |
| 25 | + uses: pnpm/action-setup@v4 |
53 | 26 | with: |
54 | | - version: "9.7.0" |
| 27 | + version: '9' |
| 28 | + |
55 | 29 | - name: Setup Node |
56 | 30 | uses: actions/setup-node@v4 |
57 | 31 | 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 | + |
61 | 35 | - 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 | + |
64 | 38 | - name: Install noto-cjk |
65 | 39 | run: sudo apt-get install -y fonts-noto-cjk |
| 40 | + |
66 | 41 | - 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 |
72 | 46 | with: |
73 | 47 | apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
74 | 48 | accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
75 | | - projectName: "blog" # e.g. 'my-project' |
76 | | - directory: "dist" # e.g. 'dist' |
77 | | - gitHubToken: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments