From 6bb12c3c12045ead59e6400be01973df46be3dce Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 17 Sep 2026 11:49:21 -0500 Subject: [PATCH] ci: drop the Gitea mirror entirely octowow.st's Gitea instance would not accept a git push under any credential scheme, converting the repo off "mirror" status didn't change that, and its own pull-mirror sync was already unreliable before any of that -- three commits of narrowing down the actual cause without ever reaching a fix. The repo is being removed from Gitea, so there is nothing left to mirror to. Removes mirror-release.yml, the diagnose-mirror-auth.yml scratch workflow, and the `mirror` job in build.yml that called it. --- .github/workflows/build.yml | 15 -- .github/workflows/diagnose-mirror-auth.yml | 81 -------- .github/workflows/mirror-release.yml | 207 --------------------- 3 files changed, 303 deletions(-) delete mode 100644 .github/workflows/diagnose-mirror-auth.yml delete mode 100644 .github/workflows/mirror-release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e946b96..bbf1cbf7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,6 @@ jobs: build: needs: pick-runner runs-on: ${{ needs.pick-runner.outputs.label }} - # Handed to the `mirror` job below, which cannot see this job's steps. outputs: tag: ${{ steps.ver.outputs.tag }} is_release: ${{ steps.ver.outputs.is_release }} @@ -151,17 +150,3 @@ jobs: build/Release/ClassicAPI.dll build/Release/Crash-Symbols-Use-For-Debugging-${{ steps.ver.outputs.tag }}.zip generate_release_notes: true - - # The Gitea mirror pulls commits and tags but never releases, so hand the - # finished release across to it. A separate job on purpose: the DLL is - # already published on GitHub by this point, so a mirror problem shows up on - # its own instead of failing the release build. A `release: published` event - # would not work here — releases made with the default GITHUB_TOKEN do not - # start another workflow. - mirror: - needs: build - if: needs.build.outputs.is_release == 'true' - uses: ./.github/workflows/mirror-release.yml - with: - tag: ${{ needs.build.outputs.tag }} - secrets: inherit diff --git a/.github/workflows/diagnose-mirror-auth.yml b/.github/workflows/diagnose-mirror-auth.yml deleted file mode 100644 index 273d2017..00000000 --- a/.github/workflows/diagnose-mirror-auth.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Diagnose mirror auth - -# One-shot diagnostic. mirror-release.yml has now failed to git-push a tag -# to the Gitea mirror under two different credential schemes -- both with -# the identical client-side error, which is what a git client prints for -# ANY non-git-protocol response (a 401, a 403, an error page all look the -# same from outside). A first round of this diagnostic checked only HTTP -# status codes on the GET (info/refs) leg and every scheme came back 200 -- -# which does not actually clear anything: a curl status-code check can't -# tell a real git advertisement body apart from a 200 that is something -# else (a proxy/WAF page, a truncated response), and `git push` also does -# a second POST leg that a GET-only probe never touches at all. -# -# This round runs the real thing: `git push --dry-run` end to end, with -# the real MIRROR_TOKEN, against a disposable ref that nothing depends on -# (refs/heads/_diagnose-mirror-auth) -- dry-run negotiates the full -# exchange but updates nothing server-side. Captures git's own real -# output this time instead of inferring from a client-side parse error. -# Also dumps the raw Content-Type/body-prefix of the GET leg so a -# malformed-200 can be told apart from a genuine advertisement. -# -# Safe to paste the output back anywhere -- no token or repo content -# appears in it, only git's own diagnostic text and generic HTTP headers. -# -# Delete this file once the working scheme is found and applied to -# mirror-release.yml. - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - diagnose: - runs-on: ubuntu-latest - steps: - - name: Probe the real push path - env: - MIRROR_TOKEN: ${{ secrets.MIRROR_TOKEN }} - run: | - set -uo pipefail - - if [ -z "${MIRROR_TOKEN:-}" ]; then - echo "::error::MIRROR_TOKEN is not set" - exit 1 - fi - - MIRROR=brues/ClassicAPI - GIT="https://octowow.st/git/$MIRROR.git" - REF=refs/heads/_diagnose-mirror-auth - - echo "=== raw GET info/refs (receive-pack) -- headers + first 300 bytes of body ===" - curl -sS -m 20 -D - -H "Authorization: token ${MIRROR_TOKEN}" \ - "$GIT/info/refs?service=git-receive-pack" 2>&1 | head -c 600 - echo - echo - - work=$(mktemp -d) - git init -q "$work" - git -C "$work" -c user.email=diag@example.invalid -c user.name=diag \ - commit -q --allow-empty -m diag - - echo "=== git push --dry-run: Authorization header (what push_tag currently uses) ===" - git -C "$work" -c http.extraHeader="Authorization: token ${MIRROR_TOKEN}" \ - push --dry-run -v "$GIT" "HEAD:$REF" 2>&1 - echo "exit: $?" - echo - - echo "=== git push --dry-run: Basic auth, real username (brues:) ===" - git -C "$work" push --dry-run -v \ - "https://brues:${MIRROR_TOKEN}@octowow.st/git/$MIRROR.git" "HEAD:$REF" 2>&1 - echo "exit: $?" - echo - - echo "=== git push --dry-run: Basic auth, token as username, blank password ===" - git -C "$work" push --dry-run -v \ - "https://${MIRROR_TOKEN}@octowow.st/git/$MIRROR.git" "HEAD:$REF" 2>&1 - echo "exit: $?" - - rm -rf "$work" diff --git a/.github/workflows/mirror-release.yml b/.github/workflows/mirror-release.yml deleted file mode 100644 index 52817c94..00000000 --- a/.github/workflows/mirror-release.yml +++ /dev/null @@ -1,207 +0,0 @@ -name: Mirror release - -# Copy a GitHub release — its notes and the files attached to it — across to -# the Gitea mirror at https://octowow.st/git/brues/ClassicAPI. -# -# A Gitea pull mirror replicates commits and tags only. Releases are database -# records with their own attachments, so they never cross: the mirror's -# Releases page shows bare tags with nothing to download. This workflow pushes -# them over through Gitea's API. -# -# A release must hang off a tag that already exists on the mirror. Gitea's -# own pull-mirror sync is supposed to keep tags current, but its background -# fetch job can fail silently (stale credentials on Gitea's side, a stuck -# queue) with nothing visible from the GitHub side — so instead of triggering -# that sync and polling for the tag to show up, this workflow pushes the tag -# there itself with MIRROR_TOKEN before touching the release. Gitea's pull -# mirror can keep doing its own thing for everyday commits/branches; this -# workflow no longer depends on it working. -# -# ONE-TIME SETUP: on the mirror, go to Settings -> Applications -> Generate New -# Token, tick `repository` write, and copy the token. On GitHub, add it under -# Settings -> Secrets and variables -> Actions as `MIRROR_TOKEN`. The token -# needs push rights on brues/ClassicAPI. -# -# Two ways in: -# - `Build` calls it after every release build (see the `mirror` job there). -# - Run it from the Actions UI with a `tag` to redo one release, or with -# `tag` left blank to backfill every release that exists on GitHub. - -on: - workflow_call: - inputs: - tag: - required: true - type: string - workflow_dispatch: - inputs: - tag: - description: 'Release tag to mirror (e.g. v2.0.0). Blank = every release.' - required: false - default: '' - -permissions: - contents: read - -jobs: - mirror: - runs-on: ubuntu-latest - steps: - # No checkout: the release files come from the GitHub release itself, so - # this reads the same bytes a user downloads rather than a rebuild. - - name: Push release to the mirror - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - MIRROR_TOKEN: ${{ secrets.MIRROR_TOKEN }} - TAG: ${{ inputs.tag }} - run: | - set -euo pipefail - - if [ -z "${MIRROR_TOKEN:-}" ]; then - echo "::error::MIRROR_TOKEN is not set - see the setup note at the top of .github/workflows/mirror-release.yml" - exit 1 - fi - - API=https://octowow.st/git/api/v1 - MIRROR=brues/ClassicAPI - RESP=$(mktemp) - - # Sends one API call. Prints the HTTP status; leaves the body in $RESP. - req() { - local method=$1 path=$2 - shift 2 - curl -sS -m 600 -o "$RESP" -w '%{http_code}' -X "$method" \ - -H "Authorization: token $MIRROR_TOKEN" \ - -H 'Accept: application/json' \ - "$API/$path" "$@" - } - - fail() { - echo "::error::$1" - echo "the mirror replied: $(head -c 2000 "$RESP")" - exit 1 - } - - # A release must hang off a tag that is already on the mirror. Push - # it there ourselves rather than asking Gitea's pull-mirror to go - # fetch it: that sync runs as a background queue job, and the POST - # below only enqueues it — a failure on Gitea's end (stale pull - # credentials, a stuck queue) is invisible here, so we would just - # poll until the timeout. A direct push is synchronous: it either - # lands or fails loudly on the spot. - push_tag() { - local tag=$1 work - work=$(mktemp -d) - git init -q "$work" - if ! git -C "$work" fetch -q --depth 1 \ - "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" \ - "refs/tags/$tag:refs/tags/$tag"; then - echo "::error::could not fetch tag $tag from GitHub" - exit 1 - fi - # `oauth2:` as HTTP Basic auth is GitLab's convention, not - # Gitea's, and Gitea's git-http endpoint rejects it (401 -- git - # renders any 401 here as the confusing "could not determine - # hash algorithm" message, not a clear auth error). Send the - # same `Authorization: token X` scheme the curl calls above - # already use successfully against this server, rather than - # guess at a Basic-auth username. - if ! git -C "$work" \ - -c http.extraHeader="Authorization: token ${MIRROR_TOKEN}" \ - push -q "https://octowow.st/git/$MIRROR.git" "refs/tags/$tag"; then - echo "::error::could not push tag $tag to the mirror" - exit 1 - fi - rm -rf "$work" - } - - mirror_one() { - local tag=$1 work code id f name size have_id have_size enc - work=$(mktemp -d) - echo "=== $tag ===" - - gh release view "$tag" --json tagName,name,body,isDraft,isPrerelease > "$work/gh.json" - if [ "$(jq -r .isDraft "$work/gh.json")" = true ]; then - echo " still a draft on GitHub - skipped" - return 0 - fi - - push_tag "$tag" - - jq '{tag_name: .tagName, - name: (.name // .tagName), - body: (.body // ""), - draft: false, - prerelease: .isPrerelease}' "$work/gh.json" > "$work/release.json" - - # Gitea's tag sync leaves a bare tag record behind. Patching it - # promotes that record to a real release instead of colliding. - code=$(req GET "repos/$MIRROR/releases/tags/$tag") - if [ "$code" = 200 ]; then - id=$(jq -r .id "$RESP") - code=$(req PATCH "repos/$MIRROR/releases/$id" \ - -H 'Content-Type: application/json' --data-binary @"$work/release.json") - if [ "$code" != 200 ]; then - fail "could not update release $tag on the mirror (HTTP $code)" - fi - echo " updated release #$id" - else - code=$(req POST "repos/$MIRROR/releases" \ - -H 'Content-Type: application/json' --data-binary @"$work/release.json") - if [ "$code" != 201 ]; then - fail "could not create release $tag on the mirror (HTTP $code)" - fi - id=$(jq -r .id "$RESP") - echo " created release #$id" - fi - - mkdir -p "$work/assets" - # Exits non-zero when the release carries no files, which is fine. - gh release download "$tag" --dir "$work/assets" --clobber || true - - code=$(req GET "repos/$MIRROR/releases/$id/assets") - if [ "$code" != 200 ]; then - fail "could not list the mirror's attachments for $tag (HTTP $code)" - fi - cp "$RESP" "$work/have.json" - - for f in "$work"/assets/*; do - [ -f "$f" ] || continue - name=$(basename "$f") - size=$(stat -c %s "$f") - have_id=$(jq -r --arg n "$name" 'map(select(.name == $n)) | .[0].id // ""' "$work/have.json") - have_size=$(jq -r --arg n "$name" 'map(select(.name == $n)) | .[0].size // ""' "$work/have.json") - - # Same name and same size: already mirrored. A size mismatch means - # a re-cut release, so replace it - Gitea would otherwise keep both - # and serve the stale one from the older link. - if [ -n "$have_id" ] && [ "$have_size" = "$size" ]; then - echo " $name is already there" - continue - fi - if [ -n "$have_id" ]; then - req DELETE "repos/$MIRROR/releases/$id/assets/$have_id" > /dev/null - fi - - enc=$(jq -rn --arg n "$name" '$n | @uri') - code=$(req POST "repos/$MIRROR/releases/$id/assets?name=$enc" -F "attachment=@$f") - if [ "$code" != 201 ]; then - fail "could not upload $name (HTTP $code)" - fi - echo " uploaded $name ($size bytes)" - done - } - - if [ -n "${TAG:-}" ]; then - mirror_one "$TAG" - else - echo "no tag given - backfilling every release on GitHub" - gh release list --limit 200 --json tagName --jq '.[].tagName' > /tmp/tags.txt - # fd 3 keeps gh and curl from eating the tag list off stdin. - while read -r t <&3; do - if [ -n "$t" ]; then - mirror_one "$t" - fi - done 3< /tmp/tags.txt - fi