fix(ci): sync updates.xml via API instead of git checkout (#34)

The git checkout approach fails when dev and main have diverged.
Use Gitea Contents API (PUT) to update updates.xml on target branches
directly, matching the pattern already used in auto-release.yml.

Fixes #34

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-21 21:34:18 -05:00
parent 7f9c3f2ab0
commit 03801ff925
+15 -12
View File
@@ -336,23 +336,26 @@ jobs:
if: steps.platform.outputs.platform == 'joomla'
run: |
CURRENT_BRANCH="${{ github.ref_name }}"
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
git config --local user.name "gitea-actions[bot]"
TOKEN="${{ secrets.GA_TOKEN }}"
API="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
VERSION="${{ steps.meta.outputs.version }}"
# Sync updates.xml to main and dev (whichever isn't current)
# Sync updates.xml to main and dev via API (avoids git checkout conflicts)
for BRANCH in main dev; do
[ "$BRANCH" = "$CURRENT_BRANCH" ] && continue
echo "Syncing updates.xml ${BRANCH}"
git fetch origin "${BRANCH}" 2>/dev/null || continue
git checkout "origin/${BRANCH}" -- . 2>/dev/null || continue
git checkout "${CURRENT_BRANCH}" -- updates.xml
if ! git diff --quiet updates.xml 2>/dev/null; then
git add updates.xml
git commit -m "chore: sync updates.xml from ${CURRENT_BRANCH} [skip ci]"
git push origin HEAD:refs/heads/${BRANCH} 2>&1 || echo "WARNING: push to ${BRANCH} failed"
echo "Syncing updates.xml -> ${BRANCH}"
FILE_SHA=$(curl -sf -H "Authorization: token ${TOKEN}" "${API}/contents/updates.xml?ref=${BRANCH}" | jq -r '.sha // empty' 2>/dev/null || true)
if [ -z "$FILE_SHA" ]; then
echo " WARNING: could not get updates.xml SHA from ${BRANCH}"
continue
fi
git checkout "${CURRENT_BRANCH}" 2>/dev/null
CONTENT=$(base64 -w0 updates.xml)
curl -sf -X PUT -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" "${API}/contents/updates.xml" -d "$(jq -n --arg content \"$CONTENT\" --arg sha \"$FILE_SHA\" --arg msg \"chore: sync updates.xml ${VERSION} from ${CURRENT_BRANCH} [skip ci]\" --arg branch \"$BRANCH\" '{content: $content, sha: $sha, message: $msg, branch: $branch}'
)" > /dev/null 2>&1 && echo " Synced to ${BRANCH}" || echo " WARNING: push to ${BRANCH} failed"
done
- name: "Delete lesser pre-release channels (cascade)"