Skip to content

Commit 730e3ff

Browse files
ci(deploy): simplify gh-pages workflow and pause Azure CI/CD
Remove the upload-r2 job and publish_source dispatch input from docs-deploy-gh-pages.yml; Cloudflare direct publish is now handled outside this workflow. Add wrangler.jsonc to the gh-pages payload contract and assemble step. Pause the Azure Static Web Apps workflow by converting its triggers to workflow_dispatch only. Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent efa2320 commit 730e3ff

3 files changed

Lines changed: 18 additions & 214 deletions

File tree

.github/gh-pages/wrangler.jsonc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "hagicode-docs",
3+
"compatibility_date": "2026-05-04",
4+
// Cloudflare Pages should treat the validated gh-pages dist/ snapshot as the web root.
5+
"pages_build_output_dir": "./dist",
6+
// Bindings stay in source control alongside the published payload contract.
7+
// Set bucket_name from the Cloudflare project when wiring the production bucket.
8+
"r2_buckets": [
9+
{
10+
"binding": "docs"
11+
}
12+
]
13+
}

.github/workflows/azure-static-web-apps-agreeable-stone-04924c800.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
name: Azure Static Web Apps CI/CD
1+
name: Azure Static Web Apps CI/CD (Paused)
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
types: [opened, synchronize, reopened, closed]
9-
branches:
10-
- main
4+
workflow_dispatch:
115

126
concurrency:
137
group: azure-static-web-apps-agreeable-stone-04924c800-${{ github.event.pull_request.number || github.ref }}

.github/workflows/docs-deploy-gh-pages.yml

Lines changed: 3 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ on:
55
branches:
66
- main
77
workflow_dispatch:
8-
inputs:
9-
publish_source:
10-
description: Select the source used for a manual publication run.
11-
required: true
12-
default: latest-gh-pages
13-
type: choice
14-
options:
15-
- latest-gh-pages
16-
- current-ref-build
178

189
concurrency:
1910
group: docs-deploy-gh-pages
@@ -35,60 +26,30 @@ jobs:
3526
contents: read
3627
steps:
3728
- name: Checkout current source ref
38-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
3929
uses: actions/checkout@v4
4030

41-
- name: Checkout latest gh-pages source
42-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_source == 'latest-gh-pages' }}
43-
uses: actions/checkout@v4
44-
with:
45-
ref: gh-pages
46-
fetch-depth: 1
47-
4831
- name: Setup Node.js
49-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
5032
uses: actions/setup-node@v4
5133
with:
5234
node-version: ${{ env.NODE_VERSION }}
5335
cache: npm
5436

5537
- name: Install dependencies
56-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
5738
run: npm ci
5839

5940
- name: Build and verify docs
60-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
6141
run: npm run build:ci
6242
env:
6343
CLARITY_PROJECT_ID: ${{ secrets.CLARITY_PROJECT_ID }}
6444

6545
- name: Assemble gh-pages publication payload
66-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
6746
run: |
6847
rm -rf "${DOCS_GH_PAGES_PAYLOAD_DIR}"
6948
mkdir -p "${DOCS_GH_PAGES_PAYLOAD_DIR}/dist"
7049
cp .github/gh-pages/esa.jsonc "${DOCS_GH_PAGES_PAYLOAD_DIR}/esa.jsonc"
50+
cp .github/gh-pages/wrangler.jsonc "${DOCS_GH_PAGES_PAYLOAD_DIR}/wrangler.jsonc"
7151
cp -R dist/. "${DOCS_GH_PAGES_PAYLOAD_DIR}/dist/"
7252
73-
- name: Assemble payload from latest gh-pages branch
74-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_source == 'latest-gh-pages' }}
75-
run: |
76-
if [ ! -f "esa.jsonc" ]; then
77-
echo "::error title=Missing gh-pages payload::The latest gh-pages branch snapshot does not contain esa.jsonc."
78-
exit 1
79-
fi
80-
81-
if [ ! -d "dist" ]; then
82-
echo "::error title=Missing gh-pages dist::The latest gh-pages branch snapshot does not contain dist/."
83-
exit 1
84-
fi
85-
86-
rm -rf "${DOCS_GH_PAGES_PAYLOAD_DIR}"
87-
mkdir -p "${DOCS_GH_PAGES_PAYLOAD_DIR}/dist"
88-
cp esa.jsonc "${DOCS_GH_PAGES_PAYLOAD_DIR}/esa.jsonc"
89-
cp -R dist/. "${DOCS_GH_PAGES_PAYLOAD_DIR}/dist/"
90-
echo "Prepared publication payload from the latest gh-pages branch snapshot for manual publication."
91-
9253
- name: Upload validated gh-pages payload
9354
uses: actions/upload-artifact@v4
9455
with:
@@ -98,7 +59,6 @@ jobs:
9859

9960
deploy:
10061
name: Publish validated snapshot to gh-pages
101-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish_source == 'current-ref-build' }}
10262
runs-on: ubuntu-latest
10363
needs: build
10464
permissions:
@@ -131,170 +91,7 @@ jobs:
13191
echo "## Publication status" >> "$GITHUB_STEP_SUMMARY"
13292
echo "- Publication source: validated build artifact" >> "$GITHUB_STEP_SUMMARY"
13393
echo "- \`gh-pages\` publication: succeeded" >> "$GITHUB_STEP_SUMMARY"
134-
echo "- R2 upload: pending downstream \`upload-r2\` job using the validated \`docs-gh-pages-payload\` artifact" >> "$GITHUB_STEP_SUMMARY"
135-
echo "- Published payload: branch-root \`esa.jsonc\` plus \`dist/\`" >> "$GITHUB_STEP_SUMMARY"
94+
echo "- Published payload: branch-root \`esa.jsonc\`, \`wrangler.jsonc\`, plus \`dist/\`" >> "$GITHUB_STEP_SUMMARY"
13695
echo "- GitHub environment: docs-production" >> "$GITHUB_STEP_SUMMARY"
13796
echo "- Expected public URL: https://docs.hagicode.com" >> "$GITHUB_STEP_SUMMARY"
138-
echo "Published the validated gh-pages payload with ./esa.jsonc and ./dist/."
139-
echo "gh-pages remains authoritative; the downstream R2 upload reuses docs-gh-pages-payload without rebuilding docs."
140-
141-
upload-r2:
142-
name: Upload dist contents to R2
143-
if: ${{ always() && needs.build.result == 'success' && (needs.deploy.result == 'success' || needs.deploy.result == 'skipped') }}
144-
runs-on: ubuntu-latest
145-
needs:
146-
- build
147-
- deploy
148-
permissions:
149-
contents: read
150-
environment:
151-
name: docs-production
152-
url: https://docs.hagicode.com
153-
steps:
154-
- name: Download validated gh-pages payload
155-
uses: actions/download-artifact@v4
156-
with:
157-
name: docs-gh-pages-payload
158-
path: .deploy/gh-pages
159-
160-
- name: Validate R2 configuration
161-
id: validate-r2
162-
env:
163-
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
164-
R2_BUCKET: ${{ secrets.R2_BUCKET }}
165-
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
166-
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
167-
R2_PREFIX: ${{ secrets.R2_PREFIX }}
168-
run: |
169-
required_vars=(
170-
R2_ENDPOINT
171-
R2_BUCKET
172-
R2_ACCESS_KEY_ID
173-
R2_SECRET_ACCESS_KEY
174-
)
175-
missing=()
176-
177-
for var_name in "${required_vars[@]}"; do
178-
if [ -z "${!var_name}" ]; then
179-
missing+=("${var_name}")
180-
fi
181-
done
182-
183-
normalized_prefix="${R2_PREFIX#/}"
184-
normalized_prefix="${normalized_prefix%/}"
185-
186-
if [ -n "${normalized_prefix}" ]; then
187-
target_root="s3://${R2_BUCKET}/${normalized_prefix}"
188-
prefix_display="${normalized_prefix}"
189-
else
190-
target_root="s3://${R2_BUCKET}"
191-
prefix_display="<bucket-root>"
192-
fi
193-
194-
if [ "${#missing[@]}" -gt 0 ]; then
195-
echo "::error title=Missing R2 configuration::Missing required settings: ${missing[*]}"
196-
echo "R2 upload configuration is incomplete. Missing: ${missing[*]}"
197-
exit 1
198-
fi
199-
200-
echo "target_root=${target_root}" >> "$GITHUB_OUTPUT"
201-
echo "prefix_display=${prefix_display}" >> "$GITHUB_OUTPUT"
202-
echo "normalized_prefix=${normalized_prefix}" >> "$GITHUB_OUTPUT"
203-
204-
echo "Resolved R2 endpoint: ${R2_ENDPOINT}"
205-
echo "Resolved R2 bucket: ${R2_BUCKET}"
206-
echo "Resolved R2 prefix root: ${prefix_display}"
207-
echo "Uploading .deploy/gh-pages/dist/ contents directly to ${target_root}/ without adding an extra dist/ path segment."
208-
209-
- name: Upload validated dist contents to R2
210-
id: sync-r2
211-
env:
212-
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
213-
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
214-
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
215-
AWS_DEFAULT_REGION: auto
216-
AWS_REGION: auto
217-
TARGET_ROOT: ${{ steps.validate-r2.outputs.target_root }}
218-
run: |
219-
echo "Starting R2 sync from .deploy/gh-pages/dist/ to ${TARGET_ROOT}/."
220-
aws s3 sync .deploy/gh-pages/dist/ "${TARGET_ROOT}/" \
221-
--delete \
222-
--endpoint-url "${R2_ENDPOINT}" \
223-
--no-progress
224-
225-
- name: Summarize publication result
226-
if: ${{ always() }}
227-
env:
228-
R2_BUCKET: ${{ secrets.R2_BUCKET }}
229-
R2_PREFIX: ${{ secrets.R2_PREFIX }}
230-
PUBLISH_SOURCE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_source || 'current-ref-build' }}
231-
VALIDATE_OUTCOME: ${{ steps.validate-r2.outcome }}
232-
SYNC_OUTCOME: ${{ steps.sync-r2.outcome }}
233-
TARGET_ROOT: ${{ steps.validate-r2.outputs.target_root }}
234-
PREFIX_DISPLAY: ${{ steps.validate-r2.outputs.prefix_display }}
235-
run: |
236-
normalized_prefix="${R2_PREFIX#/}"
237-
normalized_prefix="${normalized_prefix%/}"
238-
239-
if [ -n "${TARGET_ROOT}" ]; then
240-
resolved_target="${TARGET_ROOT}"
241-
elif [ -n "${normalized_prefix}" ]; then
242-
resolved_target="s3://${R2_BUCKET:-<missing>}/${normalized_prefix}"
243-
else
244-
resolved_target="s3://${R2_BUCKET:-<missing>}"
245-
fi
246-
247-
if [ -n "${PREFIX_DISPLAY}" ]; then
248-
resolved_prefix="${PREFIX_DISPLAY}"
249-
elif [ -n "${normalized_prefix}" ]; then
250-
resolved_prefix="${normalized_prefix}"
251-
else
252-
resolved_prefix="<bucket-root>"
253-
fi
254-
255-
if [ "${PUBLISH_SOURCE}" = "latest-gh-pages" ]; then
256-
gh_pages_status="reused latest gh-pages branch snapshot (manual dispatch)"
257-
publication_mode="manual replay from latest gh-pages"
258-
else
259-
gh_pages_status="succeeded"
260-
publication_mode="validated build artifact"
261-
fi
262-
263-
if [ "${VALIDATE_OUTCOME}" != "success" ]; then
264-
r2_status="failed before transfer"
265-
if [ "${PUBLISH_SOURCE}" = "latest-gh-pages" ]; then
266-
publication_status="Manual publication reused the latest gh-pages branch snapshot, but the R2 upload stopped during configuration validation."
267-
else
268-
publication_status="gh-pages publication succeeded, but the R2 upload stopped during configuration validation."
269-
fi
270-
elif [ "${SYNC_OUTCOME}" = "success" ]; then
271-
r2_status="succeeded"
272-
if [ "${PUBLISH_SOURCE}" = "latest-gh-pages" ]; then
273-
publication_status="Manual publication succeeded: the latest gh-pages branch snapshot was uploaded to R2."
274-
else
275-
publication_status="Dual-channel publication succeeded: gh-pages and R2 are both up to date."
276-
fi
277-
else
278-
r2_status="failed during transfer"
279-
if [ "${PUBLISH_SOURCE}" = "latest-gh-pages" ]; then
280-
publication_status="Manual publication reused the latest gh-pages branch snapshot, but the R2 upload failed during object sync."
281-
else
282-
publication_status="gh-pages publication succeeded, but the R2 upload failed during object sync."
283-
fi
284-
fi
285-
286-
echo "## Publication status" >> "$GITHUB_STEP_SUMMARY"
287-
echo "- Publication source: ${publication_mode}" >> "$GITHUB_STEP_SUMMARY"
288-
echo "- \`gh-pages\` publication: ${gh_pages_status}" >> "$GITHUB_STEP_SUMMARY"
289-
echo "- R2 upload: ${r2_status}" >> "$GITHUB_STEP_SUMMARY"
290-
echo "- R2 bucket: \`${R2_BUCKET:-<missing>}\`" >> "$GITHUB_STEP_SUMMARY"
291-
echo "- R2 prefix root: \`${resolved_prefix}\`" >> "$GITHUB_STEP_SUMMARY"
292-
echo "- Resolved R2 target: \`${resolved_target}\`" >> "$GITHUB_STEP_SUMMARY"
293-
echo "- Upload mapping: \`.deploy/gh-pages/dist/\` contents -> target root (no extra \`dist/\` segment)" >> "$GITHUB_STEP_SUMMARY"
294-
echo "- Result: ${publication_status}" >> "$GITHUB_STEP_SUMMARY"
295-
296-
echo "${publication_status}"
297-
echo "Resolved R2 bucket: ${R2_BUCKET:-<missing>}"
298-
echo "Resolved R2 prefix root: ${resolved_prefix}"
299-
echo "Resolved R2 target: ${resolved_target}"
300-
echo "Upload mapping: .deploy/gh-pages/dist/ contents -> target root (no extra dist/ segment)"
97+
echo "Published the validated gh-pages payload with ./esa.jsonc, ./wrangler.jsonc, and ./dist/."

0 commit comments

Comments
 (0)