66 Commits

Author SHA1 Message Date
jmiller 5fe246908c Merge pull request 'fix: move workflow-sync-trigger to custom/' (#15) from fix/move-workflow-sync-trigger into main
fix: move workflow-sync-trigger to custom/ [skip ci]
2026-06-30 18:06:50 +00:00
jmiller 1503cca367 chore: remove old workflow-sync-trigger from top-level [skip ci] 2026-06-30 18:03:50 +00:00
jmiller c5e5ca3261 chore: move workflow-sync-trigger to custom/ [skip ci] 2026-06-30 18:03:48 +00:00
jmiller f8a105ec7a Merge pull request 'chore(workflows): sync shared workflows from Template-Generic (main)' (#13) from fix/sync-from-generic into main 2026-06-27 19:28:50 +00:00
jmiller d70de91d3d chore(workflows): sync shared workflows from Template-Generic (main)
Authored-by: Moko Consulting
2026-06-27 14:27:39 -05:00
jmiller 6fa062a61a refactor: use ci-issue-reporter reusable workflow in repo-health [skip ci] 2026-06-25 17:27:16 +00:00
jmiller 36ce9234eb refactor: use ci-issue-reporter reusable workflow in pr-check [skip ci] 2026-06-25 17:26:47 +00:00
jmiller 444d9fc732 feat: add ci-issue-reporter reusable workflow [skip ci] 2026-06-25 17:26:02 +00:00
Moko Consulting [bot] d4e3aa57d0 fix: standardize token/URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:56:15 +00:00
Moko Consulting [bot] 026e7266b6 fix: standardize token/URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:56:09 +00:00
Moko Consulting [bot] eff49e0260 fix: standardize token/URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:55:37 +00:00
Moko Consulting [bot] a2ad009425 fix: standardize token/URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:55:31 +00:00
Moko Consulting [bot] ba05fec731 fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:27 +00:00
Moko Consulting [bot] bdd843c8d3 fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:24 +00:00
Moko Consulting [bot] 256e45f092 fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:21 +00:00
Moko Consulting [bot] 77ca6c37d4 fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:18 +00:00
Moko Consulting [bot] d5714805f8 fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:14 +00:00
Moko Consulting [bot] 780bb86b1f fix: standardize token and URL env vars to MOKOGITEA naming [skip ci] 2026-06-25 16:46:11 +00:00
jmiller f323e69fe0 chore: add version-set workflow [skip ci] 2026-06-23 22:00:28 +00:00
jmiller 43670c9e22 chore: remove security-audit.yml -- handled by MokoGitea 2026-06-23 18:05:54 +00:00
jmiller 0c60846ff6 chore: remove composer-publish.yml -- no longer needed 2026-06-23 18:00:40 +00:00
jmiller 0ce5dc1789 Merge pull request 'chore: remove automation directory' (#11) from fix/remove-automation into main 2026-06-21 23:10:31 +00:00
Jonathan Miller 698b8e9b18 chore: remove automation directory 2026-06-21 18:03:19 -05:00
jmiller 8af663df17 chore: sync auto-release.yml with semver tag support (#304) [skip ci] 2026-06-21 16:53:34 +00:00
jmiller 3e7f57c258 chore: sync auto-release.yml with semver tag support (#304) [skip ci] 2026-06-21 16:40:42 +00:00
jmiller e3e0a68a1c feat: add npm-publish workflow to MCP template 2026-06-21 05:49:31 +00:00
jmiller f216bd0f7c feat: add Composer publish workflow for Gitea registry + Packagist 2026-06-21 05:46:34 +00:00
jmiller 4c23fc5ae5 chore: delete manifest.xml (no longer used) 2026-06-21 00:19:40 +00:00
jmiller 6aee534334 refactor: merge PR workflows, reduce CI noise 2026-06-20 23:12:21 +00:00
jmiller 8ecee813dd refactor: merge PR workflows, reduce CI noise 2026-06-20 23:12:21 +00:00
jmiller d88e725cd3 refactor: merge PR workflows, reduce CI noise 2026-06-20 23:12:20 +00:00
jmiller af60e0af7e fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:17 +00:00
jmiller 1806f4f457 fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:16 +00:00
jmiller 06a23f53cc fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:16 +00:00
jmiller e8aea5bf6d fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:15 +00:00
jmiller ab5dca295e fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:14 +00:00
jmiller cf35adb1db fix: rename moko-platform to mokocli + changelog promotion in workflows 2026-06-20 17:16:13 +00:00
jmiller a5d777c62f fix(ci): restore full pre-release.yml content [skip ci] 2026-06-19 02:03:15 +00:00
jmiller 5154d97bff fix(ci): detect rebuild by branch name not version suffix [skip ci] 2026-06-19 02:01:49 +00:00
jmiller 591bfa76c3 ci: patch bump on same-branch rebuilds, minor only on elevation [skip ci] 2026-06-19 01:09:12 +00:00
jmiller dd13aff38c fix: update boilerplate references to correct repo name 2026-06-18 20:01:01 +00:00
jmiller 2aaa79c0d2 fix: update boilerplate references to correct repo name 2026-06-18 20:01:00 +00:00
jmiller 9b15d342b1 fix(ci): run repo-health on PR to main only, not on push 2026-06-18 16:39:43 +00:00
jmiller 521e4e4ba1 ci: add changelog extraction to promote-rc job [skip ci] 2026-06-18 16:37:30 +00:00
jmiller edc3316ac8 fix(ci): run CI on PR only, not on push 2026-06-18 16:13:52 +00:00
jmiller b9e4777d4a ci: deploy full pre-release workflow from mokoplatform [skip ci] 2026-06-18 13:47:53 +00:00
jmiller 1e301e7401 ci: disable auto-bump on push to dev [skip ci] 2026-06-16 20:46:33 +00:00
jmiller a9a01c322b fix(ci): rename secret refs to MOKOGITEA_TOKEN 2026-06-10 00:06:05 +00:00
jmiller 79b6aedf76 chore: sync security-audit.yml from Template-Generic [skip ci] 2026-06-07 17:51:19 +00:00
jmiller a91c05730e chore: sync pre-release.yml from Template-Generic [skip ci] 2026-06-07 17:51:19 +00:00
jmiller 1c1b23c640 chore: sync notify.yml from Template-Generic [skip ci] 2026-06-07 17:51:18 +00:00
jmiller 6f50658213 chore: sync ci-generic.yml from Template-Generic [skip ci] 2026-06-07 17:51:17 +00:00
jmiller 6a923039f8 chore: sync auto-release.yml from Template-Generic [skip ci] 2026-06-07 17:51:17 +00:00
Jonathan Miller ee15d17974 Merge remote-tracking branch 'origin/dev'
# Conflicts:
#	.mokogitea/workflows/pre-release.yml
2026-06-06 11:46:12 -05:00
jmiller e558156b11 Merge pull request 'chore: remove retired scripts directory' (#8) from dev into main
chore: remove retired scripts directory (#8)
2026-06-06 12:24:06 +00:00
jmiller 2a5aac40df chore: remove update-server workflow [skip ci] 2026-06-05 00:07:27 +00:00
jmiller a254b02b86 Merge pull request 'chore(ci): sync CI workflow updates from dev' (#7) from dev into main
chore(ci): sync CI workflow updates
2026-06-04 17:03:57 +00:00
gitea-actions[bot] 5e20194dd0 fix: ensure all pre-releases marked prerelease=true [skip ci] 2026-06-04 16:10:51 +00:00
jmiller 5fdce27fe2 chore: sync .mokogitea/workflows/pr-check.yml from moko-platform [skip ci] 2026-06-04 15:58:17 +00:00
jmiller 0de85a595f chore: sync .mokogitea/workflows/pr-check.yml from moko-platform [skip ci] 2026-06-04 15:40:43 +00:00
jmiller 89c21dee45 chore: sync .mokogitea/workflows/pr-check.yml from moko-platform [skip ci] 2026-06-04 15:32:06 +00:00
jmiller f2e3d2caa5 chore: sync .mokogitea/workflows/pr-check.yml from moko-platform [skip ci] 2026-06-04 15:18:55 +00:00
gitea-actions[bot] 419504ee4b chore: sync pre-release workflow — auto RC on PR to main [skip ci] 2026-06-04 14:45:47 +00:00
jmiller 436fa138e8 chore: sync .mokogitea/workflows/auto-release.yml from moko-platform [skip ci] 2026-06-04 14:23:20 +00:00
jmiller c606c3c453 chore: sync .mokogitea/workflows/repo-health.yml from moko-platform [skip ci] 2026-06-04 13:47:07 +00:00
jmiller aad56fc91a Merge pull request 'chore: gitignore config.json' (#5) from dev into main
fix(ci): add conflict-marker guard and remove RS_FTP_PATH_SUFFIX requirement
2026-06-03 03:50:56 +00:00
7 changed files with 120 additions and 268 deletions
-24
View File
@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
MokoStandards Repository Manifest
Template: MCP Server
See: https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home
-->
<moko-platform xmlns="https://standards.mokoconsulting.tech/moko-platform/1.0" schema-version="1.0">
<identity>
<name>Template-MCP</name>
<org>MokoConsulting</org>
<description>Template repository for Model Context Protocol (MCP) servers</description>
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
</identity>
<governance>
<platform>mcp</platform>
<standards-version>05.00.00</standards-version>
<standards-source>https://git.mokoconsulting.tech/MokoConsulting/moko-platform</standards-source>
</governance>
<build>
<language>TypeScript</language>
<package-type>mcp-server</package-type>
<entry-point>src/</entry-point>
</build>
</moko-platform>
+113
View File
@@ -0,0 +1,113 @@
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
# SPDX-License-Identifier: GPL-3.0-or-later
name: "Publish to npm"
on:
push:
branches:
- main
workflow_dispatch:
env:
MOKOGITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
jobs:
publish:
runs-on: ubuntu-latest
if: >-
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.head_commit.message, '[skip publish]')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Auto-bump patch version
run: |
API_BASE="${MOKOGITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
PKG_NAME=$(node -p "require('./package.json').name")
CURRENT=$(node -p "require('./package.json').version")
PUBLISHED=$(npm view "${PKG_NAME}@latest" version 2>/dev/null || echo "0.0.0")
if [ "$CURRENT" != "$PUBLISHED" ]; then
echo "Version ${CURRENT} not yet published, using as-is."
exit 0
fi
# Bump locally to get the new version
npm version patch --no-git-tag-version
NEW_VER=$(node -p "require('./package.json').version")
echo "Bumping ${CURRENT} -> ${NEW_VER}"
# Push via Gitea API: branch + PR + merge
BRANCH="chore/npm-version-bump"
FILEPATH="package.json"
CONTENT=$(base64 -w 0 < package.json)
COMMIT_MSG="chore: bump to ${NEW_VER} [skip ci]"
# Get current file SHA on main
FILE_SHA=$(curl -sf -H "Authorization: token ${TOKEN}" \
"${API_BASE}/contents/${FILEPATH}?ref=main" \
| python3 -c "import json,sys; print(json.load(sys.stdin).get('sha',''))" 2>/dev/null || true)
# Create chore branch from main
curl -sf -X POST -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${API_BASE}/branches" \
-d "{\"new_branch_name\":\"${BRANCH}\",\"old_branch_name\":\"main\"}" 2>/dev/null || true
# Get file SHA on chore branch (may differ if branch already existed)
BRANCH_SHA=$(curl -sf -H "Authorization: token ${TOKEN}" \
"${API_BASE}/contents/${FILEPATH}?ref=${BRANCH}" \
| python3 -c "import json,sys; print(json.load(sys.stdin).get('sha',''))" 2>/dev/null || true)
[ -n "$BRANCH_SHA" ] && FILE_SHA="$BRANCH_SHA"
# Push package.json to chore branch
PAYLOAD="{\"content\":\"${CONTENT}\",\"message\":\"${COMMIT_MSG}\",\"branch\":\"${BRANCH}\",\"sha\":\"${FILE_SHA}\"}"
HTTP=$(curl -sf -o /dev/null -w "%{http_code}" -X PUT \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"${API_BASE}/contents/${FILEPATH}" 2>/dev/null || echo "ERR")
echo "File push: HTTP ${HTTP}"
# Create PR
PR_NUM=$(curl -sf -X POST -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${API_BASE}/pulls" \
-d "{\"title\":\"${COMMIT_MSG}\",\"head\":\"${BRANCH}\",\"base\":\"main\"}" \
| python3 -c "import json,sys; print(json.load(sys.stdin).get('number',''))" 2>/dev/null || true)
if [ -n "$PR_NUM" ]; then
# Merge PR
curl -sf -X POST -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"${API_BASE}/pulls/${PR_NUM}/merge" \
-d "{\"Do\":\"merge\",\"merge_message_field\":\"${COMMIT_MSG}\"}" 2>/dev/null
echo "Version bumped via PR #${PR_NUM} (merged)"
else
echo "::warning::Could not create PR for version bump — publishing with current version"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -44,7 +44,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
token: ${{ secrets.GH_TOKEN || github.token }}
token: ${{ secrets.GH_MIRROR_TOKEN || github.token }}
fetch-depth: 0
- name: Set up PHP
@@ -55,8 +55,8 @@ jobs:
- name: Setup MokoStandards tools
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}'
GH_TOKEN: ${{ secrets.GH_MIRROR_TOKEN || github.token }}
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_MIRROR_TOKEN || github.token }}"}}'
run: |
git clone --depth 1 --branch version/04 --quiet \
"https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \
@@ -106,7 +106,7 @@ jobs:
--create-issue \
--repo "${{ github.repository }}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
GH_TOKEN: ${{ secrets.GH_MIRROR_TOKEN || github.token }}
- name: Commit updated files
if: ${{ steps.readme_version.outputs.skip != 'true' && inputs.dry_run != true }}
+1 -1
View File
@@ -13,7 +13,7 @@
# FILE INFORMATION
DEFGROUP:
INGROUP: Project.Documentation
REPO: mokoconsulting-tech/MokoStandards-Template-Generic
REPO: MokoConsulting/Template-MCP
VERSION: 00.00.01
PATH: ./CODE_OF_CONDUCT.md
BRIEF: Contributor Covenant Code of Conduct version 1.3.0
+2 -2
View File
@@ -13,13 +13,13 @@
# FILE INFORMATION
DEFGROUP:
INGROUP: Project.Documentation
REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-Template-Generic
REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-MCP
VERSION: 00.00.01
PATH: ./CONTRIBUTING.md
BRIEF: Contribution guidelines for the project
-->
# Contributing to MokoStandards-Template-Generic
# Contributing to Template-MCP
We appreciate your interest in contributing to this project! This document provides guidelines for contributing.
-237
View File
@@ -1,237 +0,0 @@
#!/usr/bin/env bash
# ============================================================================
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# FILE INFORMATION
# DEFGROUP: Automation.CI
# INGROUP: moko-platform.Automation
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
# PATH: /automation/ci-issue-reporter.sh
# VERSION: 09.23.00
# BRIEF: Creates or updates a Gitea issue when a CI gate fails.
# Deduplicates by searching open issues with the "ci-auto" label
# whose title matches the gate. If a matching issue exists, a comment
# is appended instead of opening a duplicate.
# ============================================================================
set -euo pipefail
# ── Defaults ────────────────────────────────────────────────────────────────
GITEA_URL="${GITEA_URL:-https://git.mokoconsulting.tech}"
GITEA_TOKEN="${GITEA_TOKEN:-}"
REPO="${GITHUB_REPOSITORY:-}"
RUN_URL="${GITHUB_SERVER_URL:-${GITEA_URL}}/${REPO}/actions/runs/${GITHUB_RUN_ID:-0}"
LABEL_NAME="ci-auto"
LABEL_COLOR="#e11d48"
GATE=""
DETAILS=""
SEVERITY="error"
WORKFLOW=""
# ── Parse arguments ─────────────────────────────────────────────────────────
usage() {
cat <<EOF
Usage: ci-issue-reporter.sh --gate NAME --details TEXT [OPTIONS]
Required:
--gate CI gate name (e.g. "Code Quality", "Self-Health")
--details Human-readable failure description
Optional:
--severity "error" (default) or "warning"
--workflow Workflow name for the issue title
--repo owner/repo (default: \$GITHUB_REPOSITORY)
--run-url URL to the CI run (auto-detected from env)
--token Gitea API token (default: \$GITEA_TOKEN)
--url Gitea base URL (default: \$GITEA_URL)
EOF
exit 1
}
while [[ $# -gt 0 ]]; do
case "$1" in
--gate) GATE="$2"; shift 2 ;;
--details) DETAILS="$2"; shift 2 ;;
--severity) SEVERITY="$2"; shift 2 ;;
--workflow) WORKFLOW="$2"; shift 2 ;;
--repo) REPO="$2"; shift 2 ;;
--run-url) RUN_URL="$2"; shift 2 ;;
--token) GITEA_TOKEN="$2"; shift 2 ;;
--url) GITEA_URL="$2"; shift 2 ;;
-h|--help) usage ;;
*) echo "Unknown option: $1"; usage ;;
esac
done
[[ -z "$GATE" ]] && { echo "ERROR: --gate is required"; usage; }
[[ -z "$DETAILS" ]] && { echo "ERROR: --details is required"; usage; }
[[ -z "$GITEA_TOKEN" ]] && { echo "ERROR: GITEA_TOKEN not set"; exit 1; }
[[ -z "$REPO" ]] && { echo "ERROR: GITHUB_REPOSITORY not set"; exit 1; }
API="${GITEA_URL}/api/v1/repos/${REPO}"
# ── Build title ─────────────────────────────────────────────────────────────
if [[ -n "$WORKFLOW" ]]; then
TITLE="[CI] ${WORKFLOW}: ${GATE} failed"
else
TITLE="[CI] ${GATE} failed"
fi
# ── Ensure label exists ─────────────────────────────────────────────────────
ensure_label() {
local exists
exists=$(curl -sf -o /dev/null -w '%{http_code}' \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/labels" 2>/dev/null || echo "000")
if [[ "$exists" == "200" ]]; then
# Check if label already exists
local found
found=$(curl -sf \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/labels" 2>/dev/null \
| grep -o "\"name\":\"${LABEL_NAME}\"" || true)
if [[ -z "$found" ]]; then
curl -sf -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${API}/labels" \
-d "{\"name\":\"${LABEL_NAME}\",\"color\":\"${LABEL_COLOR}\",\"description\":\"Auto-created by CI issue reporter\"}" \
> /dev/null 2>&1 || true
fi
fi
}
# ── Search for existing open issue ──────────────────────────────────────────
find_existing_issue() {
# URL-encode the gate name for the query
local query
query=$(printf '%s' "[CI] ${GATE}" | sed 's/ /%20/g; s/\[/%5B/g; s/\]/%5D/g')
local response
response=$(curl -sf \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/issues?type=issues&state=open&labels=${LABEL_NAME}&q=${query}&limit=5" \
2>/dev/null || echo "[]")
# Extract the first matching issue number
echo "$response" \
| grep -oP '"number":\s*\K[0-9]+' \
| head -1
}
# ── Build issue body ────────────────────────────────────────────────────────
build_body() {
local severity_badge
if [[ "$SEVERITY" == "error" ]]; then
severity_badge="**Severity:** Error"
else
severity_badge="**Severity:** Warning"
fi
cat <<BODY
## CI Gate Failure: ${GATE}
${severity_badge}
**Workflow:** ${WORKFLOW:-unknown}
**Branch:** ${GITHUB_REF_NAME:-unknown}
**Commit:** \`${GITHUB_SHA:0:8}\`
**Run:** [View CI run](${RUN_URL})
### Details
${DETAILS}
### Resolution
Fix the issue described above and push a new commit. This issue will be closed automatically when the gate passes, or can be closed manually.
---
*Auto-created by [ci-issue-reporter](${GITEA_URL}/${REPO}/src/branch/main/automation/ci-issue-reporter.sh)*
BODY
}
# ── Build comment body (for existing issues) ────────────────────────────────
build_comment() {
cat <<COMMENT
### CI failure recurrence
**Branch:** ${GITHUB_REF_NAME:-unknown}
**Commit:** \`${GITHUB_SHA:0:8}\`
**Run:** [View CI run](${RUN_URL})
${DETAILS}
COMMENT
}
# ── Main ────────────────────────────────────────────────────────────────────
ensure_label
EXISTING=$(find_existing_issue)
if [[ -n "$EXISTING" ]]; then
# Append comment to existing issue
COMMENT_BODY=$(build_comment)
COMMENT_JSON=$(printf '%s' "$COMMENT_BODY" | python3 -c "
import sys, json
print(json.dumps({'body': sys.stdin.read()}))" 2>/dev/null)
HTTP=$(curl -sf -o /dev/null -w '%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${API}/issues/${EXISTING}/comments" \
-d "${COMMENT_JSON}" 2>/dev/null || echo "000")
if [[ "$HTTP" == "201" ]]; then
echo "Commented on existing issue #${EXISTING}"
else
echo "WARNING: Failed to comment on issue #${EXISTING} (HTTP ${HTTP})"
fi
else
# Create new issue
ISSUE_BODY=$(build_body)
ISSUE_JSON=$(python3 -c "
import sys, json
body = sys.stdin.read()
print(json.dumps({
'title': sys.argv[1],
'body': body,
'labels': []
}))" "$TITLE" <<< "$ISSUE_BODY" 2>/dev/null)
# Create the issue
RESPONSE=$(curl -sf -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${API}/issues" \
-d "${ISSUE_JSON}" 2>/dev/null || echo "{}")
ISSUE_NUM=$(echo "$RESPONSE" | grep -oP '"number":\s*\K[0-9]+' | head -1)
if [[ -n "$ISSUE_NUM" ]]; then
# Apply label (separate call — more reliable across Gitea versions)
LABEL_ID=$(curl -sf \
-H "Authorization: token ${GITEA_TOKEN}" \
"${API}/labels" 2>/dev/null \
| grep -oP "\"id\":\s*\K[0-9]+(?=[^}]*\"name\":\s*\"${LABEL_NAME}\")" \
| head -1 || true)
if [[ -n "$LABEL_ID" ]]; then
curl -sf -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${API}/issues/${ISSUE_NUM}/labels" \
-d "{\"labels\":[${LABEL_ID}]}" \
> /dev/null 2>&1 || true
fi
echo "Created issue #${ISSUE_NUM}: ${TITLE}"
else
echo "WARNING: Failed to create issue"
echo "Response: ${RESPONSE}"
fi
fi