-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (49 loc) · 1.92 KB
/
Copy pathdeploy.yml
File metadata and controls
57 lines (49 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Deploy to Cloudflare Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: pages-deploy
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
env:
# Mapped from the secret so we can gate steps on its presence — the
# `secrets` context isn't available directly in step `if:` conditions.
CF_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Check configuration
if: ${{ env.CF_TOKEN == '' }}
run: |
echo "::notice::CLOUDFLARE_API_TOKEN not set — skipping deploy."
echo "Add CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID repo secrets to enable it."
# Stage only the files the site actually serves — keep serve.py,
# scripts/, dist/, README, and CI config out of the public deployment.
- name: Stage site
if: ${{ env.CF_TOKEN != '' }}
run: |
mkdir -p _site
cp -R index.html 404.html styles.css assets _headers _site/
[ -f _redirects ] && cp _redirects _site/ || true
echo "Staged:" && find _site -maxdepth 2 -type f | sort
# First run creates the project; later runs no-op (hence continue-on-error).
- name: Ensure Pages project exists
if: ${{ env.CF_TOKEN != '' }}
continue-on-error: true
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages project create aetherweb --production-branch main
- name: Deploy
if: ${{ env.CF_TOKEN != '' }}
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy _site --project-name=aetherweb --branch=main --commit-dirty=true