From 27d54f15a2c0249eb91d80ec7d5aa228cae718bf Mon Sep 17 00:00:00 2001 From: Docker Build Date: Sun, 10 May 2026 14:37:02 -0500 Subject: [PATCH] fix(gitea): document and explain HTTP 422 repo is empty on release create Co-authored-by: Cursor --- tools/fractured-launcher-electron/README.md | 3 ++- .../scripts/upload-release-to-gitea.sh | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/fractured-launcher-electron/README.md b/tools/fractured-launcher-electron/README.md index 970627e..77faec3 100644 --- a/tools/fractured-launcher-electron/README.md +++ b/tools/fractured-launcher-electron/README.md @@ -77,7 +77,7 @@ CI workflow **Sync release to Gitea** (`.github/workflows/gitea-release-sync.yml | **`GITEA_BASE_URL`** | `https://git.yourdomain.com` (no trailing slash) | | **`GITEA_TOKEN`** | Gitea personal access token with permission to manage releases and attachments on the target repo | | **`GITEA_OWNER`** | Organization or username on Gitea | -| **`GITEA_REPO`** | Repository name (create an empty repo on Gitea first) | +| **`GITEA_REPO`** | Repository name — must already have **at least one commit** (Gitea returns HTTP 422 “repo is empty” for zero-commit repos; push e.g. a README on **`main`** or set **`GITEA_TARGET_REF`** to your default branch) | **Optional variable** (Settings → Variables): **`GITEA_TARGET_REF`** — default branch/commitish used **only when the workflow must create a new Gitea release** and Gitea needs `target_commitish` (defaults to **`main`** in the upload script if unset). @@ -103,6 +103,7 @@ CI workflow **Sync release to Gitea** (`.github/workflows/gitea-release-sync.yml 4. **Repo name guard** — Jobs use `if: github.repository == 'Dawnforger/Fractured'`. Forks or renames must change that line or runs are skipped. 5. **Secrets** — **`GITEA_BASE_URL`**, **`GITEA_TOKEN`**, **`GITEA_OWNER`**, **`GITEA_REPO`** must be set under **Settings → Secrets and variables → Actions**. A failed “Upload to Gitea” step usually prints which is missing. 6. **Actions tab** — Open the latest **Sync release to Gitea** run; a red **build-electron** (old tag without `package-lock.json`, etc.) or **Upload to Gitea** step shows the real error. +7. **HTTP 422 `repo is empty`** — The Gitea repo has **no commits** yet. Push any initial commit (e.g. **Add README** in the Gitea web UI, or `git push` to **`main`**). Optionally set **`GITEA_TARGET_REF`** to match your real default branch if it is not **`main`**. ### Private Gitea token for players diff --git a/tools/fractured-launcher-electron/scripts/upload-release-to-gitea.sh b/tools/fractured-launcher-electron/scripts/upload-release-to-gitea.sh index 7419760..631de33 100644 --- a/tools/fractured-launcher-electron/scripts/upload-release-to-gitea.sh +++ b/tools/fractured-launcher-electron/scripts/upload-release-to-gitea.sh @@ -47,6 +47,12 @@ elif [ "$code" = "404" ]; then if [ "$code" != "201" ] && [ "$code" != "200" ]; then echo "Gitea create release failed HTTP $code:" >&2 cat "$REL_JSON" >&2 + if [ "$code" = "422" ] && jq -e '.message == "repo is empty"' "$REL_JSON" >/dev/null 2>&1; then + echo >&2 + echo "Gitea does not allow releases on a repo with zero commits. Fix: push at least one commit" >&2 + echo "to ${GITEA_OWNER}/${GITEA_REPO} (e.g. add README.md on branch ${TARGET} via web UI or git push)," >&2 + echo "or set Actions variable GITEA_TARGET_REF to an existing default branch name." >&2 + fi exit 1 fi rel_id=$(jq -r '.id' "$REL_JSON")