docs: update gitea-cloudflare pages deploy snippet to inline manifest as form arg
This commit is contained in:
1 parent
4d627e13b9
commit
7be66a703c
1 file changed
+21
-12
@@ -73,29 +73,38 @@ jobs:
|
|||||||
|
|
||||||
If the `cloudflare/pages-action@v1` action is unavailable from Gitea, use the direct Cloudflare Pages API (multipart/form-data with manifest):
|
If the `cloudflare/pages-action@v1` action is unavailable from Gitea, use the direct Cloudflare Pages API (multipart/form-data with manifest):
|
||||||
|
|
||||||
|
Snippet to generate a manifest in format `-F manifest='{"index.html": "abc123", "style.css": "def456"}'`
|
||||||
|
|
||||||
|
```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
|
```yaml
|
||||||
- name: Generate deployment manifest
|
- name: Generate deployment manifest
|
||||||
run: |
|
run: |
|
||||||
cd frontend/dist
|
cd frontend/dist
|
||||||
echo "{" > manifest.json
|
form_args="-F manifest={"
|
||||||
first=true
|
for file in $(find . -type f ! -name manifest.json | sed 's|^\./||'); do
|
||||||
for file in $(find . -type f | sed 's|^\./||'); do
|
|
||||||
hash=$(sha256sum "$file" | awk '{print $1}')
|
hash=$(sha256sum "$file" | awk '{print $1}')
|
||||||
if [ "$first" = true ]; then first=false; else echo "," >> manifest.json; fi
|
form_args="$form_args\"$file\":\"$hash\","
|
||||||
printf ' "%s": "%s"' "$file" "$hash" >> manifest.json
|
|
||||||
done
|
done
|
||||||
echo "" >> manifest.json && echo "}" >> manifest.json
|
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
|
- name: Deploy to Cloudflare Pages
|
||||||
env:
|
env:
|
||||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
run: |
|
run: |
|
||||||
cd frontend/dist
|
cd frontend/dist
|
||||||
form_args="-F manifest=@manifest.json"
|
form_args="$FORM_ARGS" # use form arguments generated in previous step
|
||||||
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")
|
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||||
curl -sS -X POST \
|
curl -sS -X POST \
|
||||||
"https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/linearvoid/deployments" \
|
"https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/linearvoid/deployments" \
|
||||||
|
|||||||
Reference in new issue
Block a user