Merge pull request #40 from adrianoftyriel/cf-first-deploy-fix

Fix first Cloudflare deploy: add first_deploy dispatch input
This commit is contained in:
adrianoftyriel
2026-10-14 09:39:58 -06:00
committed by GitHub
4 changed files with 25 additions and 0 deletions
+9
View File
@@ -25,6 +25,15 @@ cp "$apk" "$out/$channel/ProLibertateGames.apk"
jq -n --arg tag "$tag" --arg name "$name" --arg ch "$channel" --arg url "$base/$channel/$name" \ jq -n --arg tag "$tag" --arg name "$name" --arg ch "$channel" --arg url "$base/$channel/$name" \
'{tag: $tag, apkName: $name, apkUrl: $url, channel: $ch}' > "$out/$channel/latest.json" '{tag: $tag, apkName: $name, apkUrl: $url, channel: $ch}' > "$out/$channel/latest.json"
# PLG_SKIP_OTHER=1 is for the very first deploy, when the site does not exist
# yet and the domain answers 403 (Cloudflare error 1014) instead of 404.
if [ -n "${PLG_SKIP_OTHER:-}" ]; then
echo "PLG_SKIP_OTHER set; not carrying over $other."
rm -rf "$out/$other"
find "$out" -type f | sort
exit 0
fi
# Carry the other channel over. 404 means it was never published; any other # Carry the other channel over. 404 means it was never published; any other
# failure must stop the deploy rather than silently dropping that channel. # failure must stop the deploy rather than silently dropping that channel.
code="$(curl -sS -o "$out/$other/latest.json" -w '%{http_code}' "$base/$other/latest.json" || true)" code="$(curl -sS -o "$out/$other/latest.json" -w '%{http_code}' "$base/$other/latest.json" || true)"
+7
View File
@@ -16,6 +16,11 @@ on:
pull_request: pull_request:
branches: [ main, dev ] branches: [ main, dev ]
workflow_dispatch: workflow_dispatch:
inputs:
first_deploy:
description: "First Cloudflare deploy: skip carrying over the other channel (the site does not exist yet)"
type: boolean
default: false
# Needed to publish the dev-channel prerelease below. # Needed to publish the dev-channel prerelease below.
permissions: permissions:
@@ -162,6 +167,8 @@ jobs:
path: staged path: staged
- name: Assemble site - name: Assemble site
env:
PLG_SKIP_OTHER: ${{ inputs.first_deploy && '1' || '' }}
run: .github/scripts/stage-pages-site.sh dev "${{ needs.build.outputs.version }}" "staged/ProLibertateGames-${{ needs.build.outputs.version }}.apk" run: .github/scripts/stage-pages-site.sh dev "${{ needs.build.outputs.version }}" "staged/ProLibertateGames-${{ needs.build.outputs.version }}.apk"
- name: Deploy - name: Deploy
+7
View File
@@ -6,6 +6,11 @@ on:
push: push:
branches: [ main ] branches: [ main ]
workflow_dispatch: workflow_dispatch:
inputs:
first_deploy:
description: "First Cloudflare deploy: skip carrying over the other channel (the site does not exist yet)"
type: boolean
default: false
# Allow the built-in token to create releases and upload the APK. # Allow the built-in token to create releases and upload the APK.
permissions: permissions:
@@ -119,6 +124,8 @@ jobs:
path: staged path: staged
- name: Assemble site - name: Assemble site
env:
PLG_SKIP_OTHER: ${{ inputs.first_deploy && '1' || '' }}
run: .github/scripts/stage-pages-site.sh prod "${{ needs.build.outputs.version }}" "staged/ProLibertateGames-${{ needs.build.outputs.version }}.apk" run: .github/scripts/stage-pages-site.sh prod "${{ needs.build.outputs.version }}" "staged/ProLibertateGames-${{ needs.build.outputs.version }}.apk"
- name: Deploy - name: Deploy
+2
View File
@@ -216,6 +216,8 @@ because a Pages deploy replaces everything. The two share a concurrency group so
they cannot race. Needs repo secrets `CLOUDFLARE_API_TOKEN` (Account → Cloudflare they cannot race. Needs repo secrets `CLOUDFLARE_API_TOKEN` (Account → Cloudflare
Pages → Edit) and `CLOUDFLARE_ACCOUNT_ID`. Pages caps files at 25 MiB. Pages → Edit) and `CLOUDFLARE_ACCOUNT_ID`. Pages caps files at 25 MiB.
**First deploy:** the site does not exist yet, so the domain answers 403 (Cloudflare error 1014) and the carry-over fetch would abort. Dispatch the workflow once with `first_deploy` ticked, then attach `plg.wallacenet.ca` as a custom domain on the new `plg` Pages project. Later runs need no input.
The in-app updater reads these `latest.json` files. GitHub Releases are still The in-app updater reads these `latest.json` files. GitHub Releases are still
published for one transition deployment so installs that predate this change can published for one transition deployment so installs that predate this change can
fetch it; after that, remove the GitHub release steps from both workflows. fetch it; after that, remove the GitHub release steps from both workflows.