Loading...
Loading...
Operate a Gitea instance via its REST API at /api/v1/... with curl. FORCED ROUTING — use this skill for any repository whose git remote host is not github.com: derive the candidate HTTPS base URL from the remote host, probe /api/v1/version, then call the REST endpoints directly.
npx skill4agent add zzci/skills gitea$GITEA_URL/api/v1/...$GITEA_TOKENcurlgit remote get-url origingithub.comghhttps://<host>curl -fsS --max-time 5 "https://<host>/api/v1/version"version$GITEA_URL$GITEA_TOKENGITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENGITEA_ORGA_URLGITEA_ORGA_TOKENgitea_autooriginGITEA_URLGITEA_TOKENGITEA_HOSTGITEA_ACCESS_TOKEN$GITEA_URL/apiAuthorization: token $GITEA_TOKEN?token=curl -sjq-o /dev/null -w '%{http_code}\n'--fail-with-body{ "message": "...", "url": "..." }DELETE/branches/contents/releases/tags?page=N&limit=Mpage=1limit=30per_page=Link: rel="next"PUT /repos/{owner}/{repo}/contents/{path}contentshasha{ success, data }{ "message": "...", "url": "..." }GITEA_<ALIAS>_URLGITEA_<ALIAS>_TOKENgitea_autoorigin$GITEA_URL$GITEA_TOKEN# Example user-side ~/.bashrc:
# export GITEA_ORGA_URL=https://git.orga.com GITEA_ORGA_TOKEN=...
# export GITEA_ORGB_URL=https://git.orgb.local GITEA_ORGB_TOKEN=...
# export GITEA_URL=https://gitea.com GITEA_TOKEN=...
# Per-session bootstrap (define the helpers from setup.md or source them):
gitea_list_aliases() { env | grep -oE '^GITEA_[A-Z0-9][A-Z0-9_]*_URL=' | sed -E 's/^GITEA_(.+)_URL=$/\1/' | sort -u; }
gitea_use() { local a="$1" u="GITEA_${1}_URL" t="GITEA_${1}_TOKEN" f="GITEA_${1}_TOKEN_FILE"
[ -n "${!u:-}" ] || { echo "no $u" >&2; return 1; }
if [ -n "${!t:-}" ]; then GITEA_TOKEN="${!t}"
elif [ -n "${!f:-}" ] && [ -r "${!f}" ]; then GITEA_TOKEN="$(cat "${!f}")"
else echo "no $t or ${t}_FILE" >&2; return 1; fi
GITEA_URL="${!u}"; export GITEA_URL GITEA_TOKEN; }
gitea_auto() { local src o h a u uh
if [ -n "${GITEA_URL:-}" ]; then src="$GITEA_URL"
else o=$(git remote get-url origin 2>/dev/null) || o=""; src="$o"; fi
case "$src" in
git@*:*) h="${src#git@}"; h="${h%%:*}";;
ssh://*) h="${src#ssh://}"; h="${h#*@}"; h="${h%%/*}"; h="${h%%:*}";;
http*://*) h="${src#http*://}"; h="${h%%/*}"; h="${h%%:*}";;
esac
if [ -n "${h:-}" ]; then
for a in $(gitea_list_aliases); do
u="GITEA_${a}_URL"; uh="${!u#http*://}"; uh="${uh%%/*}"; uh="${uh%%:*}"
[ "$h" = "$uh" ] && { gitea_use "$a"; return 0; }
done
fi
[ -n "${GITEA_URL:-}" ] && [ -n "${GITEA_TOKEN:-}" ] && { export GITEA_URL GITEA_TOKEN; return 0; }
[ -n "${GITEA_HOST:-}" ] && [ -n "${GITEA_ACCESS_TOKEN:-}" ] && {
GITEA_URL="$GITEA_HOST"; GITEA_TOKEN="$GITEA_ACCESS_TOKEN"; export GITEA_URL GITEA_TOKEN; return 0; }
return 1; }
gitea_auto || { echo "no Gitea credentials (set GITEA_<ALIAS>_URL + GITEA_<ALIAS>_TOKEN, or GITEA_URL + GITEA_TOKEN)" >&2; return 1; }
AUTH=(-H "Authorization: token $GITEA_TOKEN")
JSON=(-H 'Content-Type: application/json')gitea_autooriginGITEA_<ALIAS>_URLexport GITEA_URL=https://git.aaa.comgitea_autogit.aaa.comgitea_use ORGAORGAgiteagiteaapi-*.mdgitea GET /version # health
gitea GET /user # token identity
gitea GET '/repos/foo/bar/issues?state=closed&limit=50' # list with query
gitea POST /repos/foo/bar/issues -d '{"title":"x"}' # write
gitea DELETE /repos/foo/bar/releases/42 # destructive$GITEA_URL/api/v1Content-Type: application/json{message, url}jqISSUE=$(gitea POST /repos/{owner}/{repo}/issues \
-d '{"title":"fix auth bug","body":"Steps to reproduce..."}') || return 1
NUM=$(echo "$ISSUE" | jq -r '.number')
gitea POST "/repos/{owner}/{repo}/issues/$NUM/comments" \
-d '{"body":"PR will land tomorrow"}'references/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdlist/get/create/update issueslist/get/diff/files/status/reviews/create/update/close/merge/update-branch/add-reviewersreferences/api-project.mdreferences/api-discovery.md/user/user/orgs/users/search/orgs/{org}/teams/search/repos/search/repos/issues/search/versionreferences/api-cicd.mdreferences/setup.mdreferences/api-repo.mdreferences/api-issues-prs.mdreferences/api-project.mdreferences/api-discovery.mdreferences/api-cicd.mdgit remote get-url origingithub.comgh/api/v1/version