From db0c7771bc12a275c95e1ca5b9fadd1a5fbff7f0 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 16 Apr 2026 22:45:09 -0500 Subject: [PATCH] Convert all gh CLI calls to Gitea API curl across workflow templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gh release view/create/edit/upload → Gitea API curl - gh api → Gitea API curl with GA_TOKEN - Download URLs point to Gitea as primary - GitHub mirror steps preserved with continue-on-error for stable/rc Affects: 11 workflow templates Co-Authored-By: Claude Opus 4.6 (1M context) --- .../workflows/dolibarr/auto-release.yml.template | 4 ++-- templates/workflows/health-check.yml | 8 ++++---- .../workflows/joomla/auto-release.yml.template | 7 +++++-- .../workflows/joomla/update-server.yml.template | 5 ++++- .../workflows/shared/auto-dev-issue.yml.template | 8 ++++---- .../workflows/shared/auto-release.yml.template | 4 ++-- .../workflows/shared/branch-freeze.yml.template | 10 +++++----- .../workflows/shared/deploy-demo.yml.template | 8 ++++---- templates/workflows/shared/deploy-dev.yml.template | 6 +++--- templates/workflows/shared/deploy-rs.yml.template | 6 +++--- .../shared/repository-cleanup.yml.template | 14 +++++++------- 11 files changed, 43 insertions(+), 37 deletions(-) diff --git a/templates/workflows/dolibarr/auto-release.yml.template b/templates/workflows/dolibarr/auto-release.yml.template index 1ba8971..45384a0 100644 --- a/templates/workflows/dolibarr/auto-release.yml.template +++ b/templates/workflows/dolibarr/auto-release.yml.template @@ -324,7 +324,7 @@ jobs: [ -z "$NOTES" ] && NOTES="Release ${VERSION}" echo "$NOTES" > /tmp/release_notes.md - EXISTING=$(gh release view "$RELEASE_TAG" --json tagName -q .tagName 2>/dev/null || true) + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".tag_name // empty" || true) if [ -z "$EXISTING" ]; then gh release create "$RELEASE_TAG" \ @@ -333,7 +333,7 @@ jobs: --target "$BRANCH" echo "Release created: ${RELEASE_TAG} (${VERSION})" >> $GITHUB_STEP_SUMMARY else - CURRENT_NOTES=$(gh release view "$RELEASE_TAG" --json body -q .body 2>/dev/null || true) + CURRENT_NOTES=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".body // empty" || true) { echo "$CURRENT_NOTES" echo "" diff --git a/templates/workflows/health-check.yml b/templates/workflows/health-check.yml index 6324828..a16c51b 100644 --- a/templates/workflows/health-check.yml +++ b/templates/workflows/health-check.yml @@ -295,16 +295,16 @@ jobs: *Auto-managed by health-check.yml — close this issue once all checks are passing.*" # Search for an existing health-check issue (any state) - EXISTING=$(gh api "repos/${REPO}/issues?labels=${LABEL}&state=all&per_page=1&sort=updated&direction=desc" \ + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?labels=${LABEL}&state=all&per_page=1&sort=updated&direction=desc" 2>/dev/null \ --jq '.[0].number' 2>/dev/null) if [ -n "$EXISTING" ] && [ "$EXISTING" != "null" ]; then # Check if it's closed — reopen if so - CURRENT_STATE=$(gh api "repos/${REPO}/issues/${EXISTING}" --jq '.state' 2>/dev/null) + CURRENT_STATE=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${EXISTING}" | jq -r '.state' 2>/dev/null) if [ "$CURRENT_STATE" = "closed" ]; then - gh api "repos/${REPO}/issues/${EXISTING}" -X PATCH -f state=open --silent + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${EXISTING}" 2>/dev/null -X PATCH -f state=open --silent fi - gh api "repos/${REPO}/issues/${EXISTING}" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${EXISTING}" 2>/dev/null \ -X PATCH \ -f title="$TITLE" \ -f body="$BODY" \ diff --git a/templates/workflows/joomla/auto-release.yml.template b/templates/workflows/joomla/auto-release.yml.template index 0bc9157..8e3828e 100644 --- a/templates/workflows/joomla/auto-release.yml.template +++ b/templates/workflows/joomla/auto-release.yml.template @@ -627,7 +627,7 @@ jobs: [ -z "$NOTES" ] && NOTES="Release ${VERSION}" echo "$NOTES" > /tmp/release_notes.md - EXISTING=$(gh release view "$RELEASE_TAG" --repo "$GH_REPO" --json tagName -q .tagName 2>/dev/null || true) + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".tag_name // empty" || true) if [ -z "$EXISTING" ]; then gh release create "$RELEASE_TAG" \ @@ -643,7 +643,10 @@ jobs: # Upload assets to GitHub mirror for PKG in /tmp/${EXT_ELEMENT:-pkg}-${VERSION}.*; do - [ -f "$PKG" ] && gh release upload "$RELEASE_TAG" "$PKG" --repo "$GH_REPO" --clobber 2>/dev/null || true + if [ -f "$PKG" ]; then + _RELID=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".id // empty") + [ -n "$_RELID" ] && curl -sf -X POST -H "Authorization: token ${{ secrets.GA_TOKEN }}" -H "Content-Type: application/octet-stream" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/${_RELID}/assets?name=$(basename $PKG)" --data-binary "@$PKG" > /dev/null 2>&1 || true + fi done echo "GitHub mirror updated: ${GH_REPO} ${RELEASE_TAG}" >> $GITHUB_STEP_SUMMARY diff --git a/templates/workflows/joomla/update-server.yml.template b/templates/workflows/joomla/update-server.yml.template index c71c507..6457116 100644 --- a/templates/workflows/joomla/update-server.yml.template +++ b/templates/workflows/joomla/update-server.yml.template @@ -348,7 +348,10 @@ jobs: echo "GitHub mirror sync for ${STABILITY} — ${GH_REPO}" >> $GITHUB_STEP_SUMMARY # Mirror packages if they exist for PKG in /tmp/*.zip /tmp/*.tar.gz; do - [ -f "$PKG" ] && gh release upload "${RELEASE_TAG}" "$PKG" --repo "$GH_REPO" --clobber 2>/dev/null || true + if [ -f "$PKG" ]; then + _RELID=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/${RELEASE_TAG}" 2>/dev/null | jq -r ".id // empty") + [ -n "$_RELID" ] && curl -sf -X POST -H "Authorization: token ${{ secrets.GA_TOKEN }}" -H "Content-Type: application/octet-stream" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/${_RELID}/assets?name=$(basename $PKG)" --data-binary "@$PKG" > /dev/null 2>&1 || true + fi done - name: SFTP deploy to dev server diff --git a/templates/workflows/shared/auto-dev-issue.yml.template b/templates/workflows/shared/auto-dev-issue.yml.template index 5670262..8fa30d4 100644 --- a/templates/workflows/shared/auto-dev-issue.yml.template +++ b/templates/workflows/shared/auto-dev-issue.yml.template @@ -85,7 +85,7 @@ jobs: TITLE="${TITLE_PREFIX}(${VERSION}): ${BRANCH_TYPE} tracking for ${BRANCH}" # Check for existing issue with same title prefix - EXISTING=$(gh api "repos/${REPO}/issues?state=open&per_page=10" \ + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?state=open&per_page=10" 2>/dev/null \ --jq ".[] | select(.title | startswith(\"${TITLE_PREFIX}(${VERSION})\")) | .number" 2>/dev/null | head -1) if [ -n "$EXISTING" ]; then @@ -163,11 +163,11 @@ jobs: for SUB in "${SUB_ISSUES[@]}"; do IFS='|' read -r SUB_TITLE _ _ <<< "$SUB" SUB_FULL_TITLE="${TITLE_PREFIX}(${VERSION}): ${SUB_TITLE}" - SUB_NUM=$(gh api "repos/${REPO}/issues?state=open&per_page=20" \ + SUB_NUM=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?state=open&per_page=20" 2>/dev/null \ --jq ".[] | select(.title == \"${SUB_FULL_TITLE}\") | .number" 2>/dev/null | head -1) if [ -n "$SUB_NUM" ]; then curl -sf -X PATCH -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/issues/${SUB_NUM}" \ - -f body="$(gh api "repos/${REPO}/issues/${SUB_NUM}" --jq '.body' 2>/dev/null) + -f body="$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${SUB_NUM}" | jq -r '.body' 2>/dev/null) > **Parent Issue:** #${PARENT_NUM}" --silent 2>/dev/null || true fi @@ -183,7 +183,7 @@ jobs: "Release Candidate") RELEASE_TAG="release-candidate" ;; esac - EXISTING=$(gh release view "$RELEASE_TAG" --json tagName -q .tagName 2>/dev/null || true) + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".tag_name // empty" || true) if [ -z "$EXISTING" ]; then gh release create "$RELEASE_TAG" \ --title "${RELEASE_TAG} (${VERSION})" \ diff --git a/templates/workflows/shared/auto-release.yml.template b/templates/workflows/shared/auto-release.yml.template index 62dabce..9b6b9ef 100644 --- a/templates/workflows/shared/auto-release.yml.template +++ b/templates/workflows/shared/auto-release.yml.template @@ -289,7 +289,7 @@ jobs: echo "$NOTES" > /tmp/release_notes.md # Check if the major release already exists - EXISTING=$(gh release view "$RELEASE_TAG" --json tagName -q .tagName 2>/dev/null || true) + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".tag_name // empty" || true) if [ -z "$EXISTING" ]; then # First release for this major: create GitHub Release @@ -300,7 +300,7 @@ jobs: echo "Release created: ${RELEASE_TAG} (${VERSION})" >> $GITHUB_STEP_SUMMARY else # Update existing major release with new version info - CURRENT_NOTES=$(gh release view "$RELEASE_TAG" --json body -q .body 2>/dev/null || true) + CURRENT_NOTES=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" 2>/dev/null | jq -r ".body // empty" || true) { echo "$CURRENT_NOTES" echo "" diff --git a/templates/workflows/shared/branch-freeze.yml.template b/templates/workflows/shared/branch-freeze.yml.template index c5063d5..f1399f5 100644 --- a/templates/workflows/shared/branch-freeze.yml.template +++ b/templates/workflows/shared/branch-freeze.yml.template @@ -45,7 +45,7 @@ jobs: run: | ACTOR="${{ github.actor }}" REPO="${{ github.repository }}" - PERMISSION=$(gh api "repos/${REPO}/collaborators/${ACTOR}/permission" \ + PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/collaborators/${ACTOR}/permission" 2>/dev/null \ --jq '.permission' 2>/dev/null || echo "read") if [ "$PERMISSION" != "admin" ]; then echo "Denied: only admins can freeze/unfreeze branches (${ACTOR} has ${PERMISSION})" @@ -66,7 +66,7 @@ jobs: if [ "$ACTION" = "freeze" ]; then # Check if ruleset already exists - EXISTING=$(gh api "repos/${REPO}/rulesets" \ + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/rulesets" 2>/dev/null \ --jq ".[] | select(.name == \"${RULESET_NAME}\") | .id" 2>/dev/null || true) if [ -n "$EXISTING" ]; then @@ -80,7 +80,7 @@ jobs: printf '"conditions":{"ref_name":{"include":["refs/heads/%s"],"exclude":[]}},' "${BRANCH}" >> /tmp/ruleset.json printf '"rules":[{"type":"update"},{"type":"deletion"},{"type":"non_fast_forward"}]}' >> /tmp/ruleset.json - RESULT=$(gh api "repos/${REPO}/rulesets" -X POST --input /tmp/ruleset.json --jq '.id' 2>&1) || true + RESULT=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/rulesets" 2>/dev/null -X POST --input /tmp/ruleset.json --jq '.id' 2>&1) || true if echo "$RESULT" | grep -qE '^[0-9]+$'; then echo "Frozen \`${BRANCH}\` — ruleset #${RESULT}" >> $GITHUB_STEP_SUMMARY @@ -98,7 +98,7 @@ jobs: elif [ "$ACTION" = "unfreeze" ]; then # Find and delete the freeze ruleset - RULESET_ID=$(gh api "repos/${REPO}/rulesets" \ + RULESET_ID=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/rulesets" 2>/dev/null \ --jq ".[] | select(.name == \"${RULESET_NAME}\") | .id" 2>/dev/null || true) if [ -z "$RULESET_ID" ]; then @@ -106,7 +106,7 @@ jobs: exit 0 fi - gh api "repos/${REPO}/rulesets/${RULESET_ID}" -X DELETE --silent 2>/dev/null + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/rulesets/${RULESET_ID}" 2>/dev/null -X DELETE --silent 2>/dev/null echo "Unfrozen \`${BRANCH}\` — ruleset #${RULESET_ID} deleted" >> $GITHUB_STEP_SUMMARY fi diff --git a/templates/workflows/shared/deploy-demo.yml.template b/templates/workflows/shared/deploy-demo.yml.template index 50eb384..8eb36ea 100644 --- a/templates/workflows/shared/deploy-demo.yml.template +++ b/templates/workflows/shared/deploy-demo.yml.template @@ -98,7 +98,7 @@ jobs: # For other actors, check repo/org permissions via API if [ "$AUTHORIZED" != "true" ]; then - PERMISSION=$(gh api "repos/${REPO}/collaborators/${ACTOR}/permission" \ + PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/collaborators/${ACTOR}/permission" 2>/dev/null \ --jq '.permission' 2>/dev/null) METHOD="repo collaborator API" @@ -588,7 +588,7 @@ jobs: FOLDER_TAG="" if [ -n "$EXT_FOLDER" ] && [ "$EXT_TYPE" = "plugin" ]; then FOLDER_TAG="${EXT_FOLDER}"; fi - DOWNLOAD_URL="https://github.com/${REPO}/releases/download/v${VERSION}/${EXT_ELEMENT}-${VERSION}.zip" + DOWNLOAD_URL="https://git.mokoconsulting.tech/${{ github.repository }}/releases/download/v${VERSION}/${EXT_ELEMENT}-${VERSION}.zip" { printf '%s\n' '' printf '%s\n' '' @@ -674,11 +674,11 @@ jobs: --force 2>/dev/null || true # Look for an existing open deploy-failure issue - EXISTING=$(gh api "repos/${REPO}/issues?labels=${LABEL}&state=all&per_page=1&sort=created&direction=desc" \ + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?labels=${LABEL}&state=all&per_page=1&sort=created&direction=desc" 2>/dev/null \ --jq '.[0].number' 2>/dev/null) if [ -n "$EXISTING" ] && [ "$EXISTING" != "null" ]; then - gh api "repos/${REPO}/issues/${EXISTING}" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${EXISTING}" 2>/dev/null \ -X PATCH \ -f title="$TITLE" \ -f body="$BODY" \ diff --git a/templates/workflows/shared/deploy-dev.yml.template b/templates/workflows/shared/deploy-dev.yml.template index ad9a0e6..25b0861 100644 --- a/templates/workflows/shared/deploy-dev.yml.template +++ b/templates/workflows/shared/deploy-dev.yml.template @@ -102,7 +102,7 @@ jobs: # For other actors, check repo/org permissions via API if [ "$AUTHORIZED" != "true" ]; then - PERMISSION=$(gh api "repos/${REPO}/collaborators/${ACTOR}/permission" \ + PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/collaborators/${ACTOR}/permission" 2>/dev/null \ --jq '.permission' 2>/dev/null) METHOD="repo collaborator API" @@ -615,7 +615,7 @@ jobs: FOLDER_TAG="${EXT_FOLDER}" fi - DOWNLOAD_URL="https://github.com/${REPO}/archive/refs/heads/${BRANCH}.zip" + DOWNLOAD_URL="https://git.mokoconsulting.tech/${{ github.repository }}/archive/refs/heads/${BRANCH}.zip" { printf '%s\n' '' @@ -631,7 +631,7 @@ jobs: printf '%s\n' ' ' printf '%s\n' " ${STABILITY}" printf '%s\n' ' ' - printf '%s\n' " https://github.com/${REPO}/tree/${BRANCH}" + printf '%s\n' " https://git.mokoconsulting.tech/${{ github.repository }}/tree/${BRANCH}" printf '%s\n' ' ' printf '%s\n' " ${DOWNLOAD_URL}" printf '%s\n' ' ' diff --git a/templates/workflows/shared/deploy-rs.yml.template b/templates/workflows/shared/deploy-rs.yml.template index 66201f2..9ace550 100644 --- a/templates/workflows/shared/deploy-rs.yml.template +++ b/templates/workflows/shared/deploy-rs.yml.template @@ -106,7 +106,7 @@ jobs: # For other actors, check repo/org permissions via API if [ "$AUTHORIZED" != "true" ]; then - PERMISSION=$(gh api "repos/${REPO}/collaborators/${ACTOR}/permission" \ + PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/collaborators/${ACTOR}/permission" 2>/dev/null \ --jq '.permission' 2>/dev/null) METHOD="repo collaborator API" @@ -616,11 +616,11 @@ jobs: --force 2>/dev/null || true # Look for an existing deploy-failure issue (any state — reopen if closed) - EXISTING=$(gh api "repos/${REPO}/issues?labels=${LABEL}&state=all&per_page=1&sort=created&direction=desc" \ + EXISTING=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?labels=${LABEL}&state=all&per_page=1&sort=created&direction=desc" 2>/dev/null \ --jq '.[0].number' 2>/dev/null) if [ -n "$EXISTING" ] && [ "$EXISTING" != "null" ]; then - gh api "repos/${REPO}/issues/${EXISTING}" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${EXISTING}" 2>/dev/null \ -X PATCH \ -f title="$TITLE" \ -f body="$BODY" \ diff --git a/templates/workflows/shared/repository-cleanup.yml.template b/templates/workflows/shared/repository-cleanup.yml.template index ac08cff..7e9889d 100644 --- a/templates/workflows/shared/repository-cleanup.yml.template +++ b/templates/workflows/shared/repository-cleanup.yml.template @@ -191,14 +191,14 @@ jobs: echo "## 🏷️ Label Reset" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - gh api "repos/${REPO}/labels?per_page=100" --paginate --jq '.[].name' | while read -r label; do + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/labels?per_page=100" 2>/dev/null --paginate --jq '.[].name' | while read -r label; do ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$label', safe=''))") gh api -X DELETE "repos/${REPO}/labels/${ENCODED}" --silent 2>/dev/null || true done while IFS='|' read -r name color description; do [ -z "$name" ] && continue - gh api "repos/${REPO}/labels" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/labels" 2>/dev/null \ -f name="$name" -f color="$color" -f description="$description" \ --silent 2>/dev/null || true done << 'LABELS' @@ -275,7 +275,7 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY FOUND=false - gh api "repos/${REPO}/branches?per_page=100" --jq '.[].name' | \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/branches?per_page=100" | jq -r '.[].name' 2>/dev/null | \ grep "^chore/sync-mokostandards" | \ grep -v "^${CURRENT}$" | while read -r branch; do gh pr list --repo "$REPO" --head "$branch" --state open --json number --jq '.[].number' 2>/dev/null | while read -r pr; do @@ -304,7 +304,7 @@ jobs: DELETED=0 # Delete cancelled and stale workflow runs for status in cancelled stale; do - gh api "repos/${REPO}/actions/runs?status=${status}&per_page=100" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/actions/runs?status=${status}&per_page=100" 2>/dev/null \ --jq '.workflow_runs[].id' 2>/dev/null | while read -r run_id; do gh api -X DELETE "repos/${REPO}/actions/runs/${run_id}" --silent 2>/dev/null || true DELETED=$((DELETED+1)) @@ -326,7 +326,7 @@ jobs: echo "Deleting logs older than: ${CUTOFF}" >> $GITHUB_STEP_SUMMARY DELETED=0 - gh api "repos/${REPO}/actions/runs?created=<${CUTOFF}&per_page=100" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/actions/runs?created=<${CUTOFF}&per_page=100" 2>/dev/null \ --jq '.workflow_runs[].id' 2>/dev/null | while read -r run_id; do gh api -X DELETE "repos/${REPO}/actions/runs/${run_id}/logs" --silent 2>/dev/null || true DELETED=$((DELETED+1)) @@ -503,10 +503,10 @@ jobs: echo "Deleting issues closed before: ${CUTOFF}" >> $GITHUB_STEP_SUMMARY DELETED=0 - gh api "repos/${REPO}/issues?state=closed&since=1970-01-01T00:00:00Z&per_page=100&sort=updated&direction=asc" \ + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues?state=closed&since=1970-01-01T00:00:00Z&per_page=100&sort=updated&direction=asc" 2>/dev/null \ --jq ".[] | select(.closed_at < \"${CUTOFF}\") | .number" 2>/dev/null | while read -r num; do # Lock and close with "not_planned" to mark as cleaned up - gh api "repos/${REPO}/issues/${num}/lock" -X PUT -f lock_reason="resolved" --silent 2>/dev/null || true + curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" "${{GITEA_URL:-https://git.mokoconsulting.tech}}/api/v1/repos/${{ github.repository }}/issues/${num}/lock" 2>/dev/null -X PUT -f lock_reason="resolved" --silent 2>/dev/null || true echo " Locked issue #${num}" >> $GITHUB_STEP_SUMMARY DELETED=$((DELETED+1)) done