From 7be66a703c38e83da55a0ed45b2f35b02e6e163d Mon Sep 17 00:00:00 2001 From: zwitschi Date: Mon, 10 Aug 2026 21:35:37 +0200 Subject: [PATCH] docs: update gitea-cloudflare pages deploy snippet to inline manifest as form arg --- docs/operations/gitea-cloudflare.pages.md | 65 +++++++++++++---------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/docs/operations/gitea-cloudflare.pages.md b/docs/operations/gitea-cloudflare.pages.md index 2158523..318ee2c 100644 --- a/docs/operations/gitea-cloudflare.pages.md +++ b/docs/operations/gitea-cloudflare.pages.md @@ -73,35 +73,44 @@ jobs: If the `cloudflare/pages-action@v1` action is unavailable from Gitea, use the direct Cloudflare Pages API (multipart/form-data with manifest): -```yaml - - name: Generate deployment manifest - run: | - cd frontend/dist - echo "{" > manifest.json - first=true - for file in $(find . -type f | sed 's|^\./||'); do - hash=$(sha256sum "$file" | awk '{print $1}') - if [ "$first" = true ]; then first=false; else echo "," >> manifest.json; fi - printf ' "%s": "%s"' "$file" "$hash" >> manifest.json - done - echo "" >> manifest.json && echo "}" >> manifest.json +Snippet to generate a manifest in format `-F manifest='{"index.html": "abc123", "style.css": "def456"}'` - - name: Deploy to Cloudflare Pages - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: | - cd frontend/dist - form_args="-F manifest=@manifest.json" - for file in $(find . -type f ! -name manifest.json | sed 's|^\./||'); do - form_args="$form_args -F $file=@$file" - done - COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") - curl -sS -X POST \ - "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/linearvoid/deployments" \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -F "commit_hash=${COMMIT_HASH}" \ - $form_args +```bash +# Build manifest form argument from all files in frontend/dist +form_args="-F manifest={" +for file in $(find frontend/dist -type f | sed 's|^frontend/dist/||'); do + hash=$(sha256sum "frontend/dist/$file" | awk '{print $1}') + form_args="$form_args\"$file\":\"$hash\"," +done +form_args="${form_args%,}}" # remove trailing comma and close JSON +``` + +```yaml +- name: Generate deployment manifest + run: | + cd frontend/dist + form_args="-F manifest={" + for file in $(find . -type f ! -name manifest.json | sed 's|^\./||'); do + hash=$(sha256sum "$file" | awk '{print $1}') + form_args="$form_args\"$file\":\"$hash\"," + done + form_args="${form_args%,}}" # remove trailing comma and close JSON + echo "Form arguments: $form_args" + echo "FORM_ARGS=$form_args" >> $GITHUB_ENV + +- name: Deploy to Cloudflare Pages + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: | + cd frontend/dist + form_args="$FORM_ARGS" # use form arguments generated in previous step + COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") + curl -sS -X POST \ + "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/linearvoid/deployments" \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -F "commit_hash=${COMMIT_HASH}" \ + $form_args ``` This matches the Cloudflare Pages Direct Upload API: `Content-Type: multipart/form-data`, each file as a separate form field, and a `manifest` JSON mapping filenames to SHA-256 hashes.