mirror of
https://github.com/Dasemu/Gitea-Claude-Webhook-Proxy.git
synced 2026-11-26 15:26:07 +00:00
Merge pull request 'chore: bootstrap Claude setup' (#1) from chore/bootstrap into main
Reviewed-on: #1
This commit is contained in:
commit
a61911ac61
7 files changed
+210
No files matched your search
@@ -0,0 +1 @@
|
||||
2
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Edit|Write",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "file=$(cat | python3 -c 'import json,sys;print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.js) node --check \"$file\" ;; esac"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "cd \"$CLAUDE_PROJECT_DIR\" && node --check server.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [development]
|
||||
push:
|
||||
branches: [development, main]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# No linter configured in this repo yet; syntax-check instead.
|
||||
- name: Syntax check
|
||||
run: node --check server.js
|
||||
|
||||
# No test suite configured in this repo yet.
|
||||
- name: Tests
|
||||
run: echo "No test suite configured yet; skipping."
|
||||
@@ -0,0 +1,82 @@
|
||||
name: Version bump
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [development, main]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
if: github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Determine bump type
|
||||
id: bump
|
||||
run: |
|
||||
if [ "${{ github.ref_name }}" = "development" ]; then
|
||||
echo "type=patch" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
# main: check whether every new commit vs. the previous main tip
|
||||
# already exists on development (i.e. this came from an approved
|
||||
# development -> main PR) rather than a direct hotfix push.
|
||||
git fetch origin development --depth=50 || true
|
||||
BEFORE="${{ github.event.before }}"
|
||||
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ]; then
|
||||
NEW_COMMITS=$(git rev-list "$BEFORE"..HEAD)
|
||||
else
|
||||
NEW_COMMITS=$(git rev-list -1 HEAD)
|
||||
fi
|
||||
FROM_DEVELOPMENT=true
|
||||
for c in $NEW_COMMITS; do
|
||||
if ! git merge-base --is-ancestor "$c" origin/development 2>/dev/null; then
|
||||
FROM_DEVELOPMENT=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$FROM_DEVELOPMENT" = "true" ] && [ -n "$NEW_COMMITS" ]; then
|
||||
echo "type=minor" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "type=patch" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Bump version
|
||||
id: version
|
||||
run: |
|
||||
CURRENT=$(node -p "require('./package.json').version")
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
|
||||
if [ "${{ steps.bump.outputs.type }}" = "minor" ]; then
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
else
|
||||
PATCH=$((PATCH + 1))
|
||||
fi
|
||||
NEW="$MAJOR.$MINOR.$PATCH"
|
||||
node -e "const fs=require('fs');const p=require('./package.json');p.version='$NEW';fs.writeFileSync('package.json', JSON.stringify(p, null, 2) + '\n');"
|
||||
echo "new=$NEW" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Commit and tag
|
||||
run: |
|
||||
git add package.json
|
||||
git commit -m "chore(release): v${{ steps.version.outputs.new }} [skip ci]"
|
||||
git push origin HEAD:${{ github.ref_name }}
|
||||
|
||||
- name: Merge main back into development
|
||||
if: github.ref_name == 'main'
|
||||
run: |
|
||||
git fetch origin development
|
||||
git checkout development
|
||||
git merge --no-edit origin/main
|
||||
git push origin development
|
||||
@@ -0,0 +1,38 @@
|
||||
# CLAUDE.md
|
||||
|
||||
## Overview
|
||||
Node.js/Express proxy that receives Gitea webhooks and forwards them to the
|
||||
Claude Code Routines API, adding headers Gitea can't send itself. See
|
||||
`README.md` for the request flow and `docs/` for deployment details.
|
||||
|
||||
## Commands
|
||||
- Dev: `npm install && cp .env.example .env` (fill in real values), then `node server.js`
|
||||
- Test: none configured yet
|
||||
- Lint: none configured yet
|
||||
- Build: none (plain Node.js, no build step)
|
||||
- Syntax check: `node --check server.js`
|
||||
|
||||
## Architecture
|
||||
Single-file Express server (`server.js`) exposing `POST /gitea-webhook` and
|
||||
`GET /health`. No database, no persistent state beyond an in-memory dedup
|
||||
cache. See `docs/` for deployment (currently Docker-only; see Gotchas).
|
||||
|
||||
## Conventions
|
||||
- CommonJS (`require`/`module.exports`), no TypeScript, no build step.
|
||||
- Keep the whole proxy in `server.js` unless it grows enough to justify splitting.
|
||||
|
||||
## Workflow quirks
|
||||
- No test suite or linter exists yet; CI only runs the syntax check.
|
||||
|
||||
## Deployment
|
||||
- Current: Docker image built from the repo `Dockerfile`, meant to run behind
|
||||
an existing nginx reverse proxy doing `proxy_pass` to `127.0.0.1:3000`.
|
||||
- The project's deployment standard (see `docs/deployment.md`) expects a
|
||||
systemd unit, an idempotent `scripts/update.sh`, and an authenticated
|
||||
update-trigger endpoint. None of these exist yet in this repo.
|
||||
|
||||
## Gotchas
|
||||
- Gitea's `X-Gitea-Event-Type` sub-event is needed to detect `issue_assign` /
|
||||
`pull_request_assign`; the coarse `X-Gitea-Event` header isn't enough (see
|
||||
README's "Known limitation" note on assignee diffing).
|
||||
- `.env` is never committed; `.env.example` lists variable names only.
|
||||
@@ -0,0 +1,6 @@
|
||||
# LESSONS.md
|
||||
|
||||
Recurring mistakes and how to avoid them. Read before starting work; add an
|
||||
entry whenever the same mistake happens twice.
|
||||
|
||||
(No recurring mistakes recorded yet.)
|
||||
@@ -0,0 +1,29 @@
|
||||
# Deployment
|
||||
|
||||
## Current state
|
||||
|
||||
The repo ships a `Dockerfile` and a `docker run` example in the README,
|
||||
meant to sit behind an existing nginx doing `proxy_pass` to
|
||||
`http://127.0.0.1:3000/gitea-webhook`.
|
||||
|
||||
## Project deployment standard
|
||||
|
||||
This project's standard deployment target for a web service is an LXC
|
||||
container or a VPS running Debian/Ubuntu, with the service managed by
|
||||
systemd (not Docker) and updated through an idempotent script triggered by
|
||||
an authenticated HTTP endpoint. As of this bootstrap, none of the following
|
||||
exist yet in this repo:
|
||||
|
||||
- [ ] A systemd unit file for the service.
|
||||
- [ ] An idempotent `scripts/update.sh` (pull, install deps, restart,
|
||||
fail-safe, logged).
|
||||
- [ ] An authenticated endpoint that triggers the update script (token-based
|
||||
auth, async run, single-flight, rate-limited, status endpoint).
|
||||
- [ ] The corresponding `UPDATE_TOKEN`-style variable in `.env.example`.
|
||||
|
||||
Setting these up is a separate task from this bootstrap; this file tracks
|
||||
what's missing so it isn't lost.
|
||||
|
||||
## Environment variables
|
||||
|
||||
See `../.env.example` and the table in `../README.md`.
|
||||
Reference in new issue
Block a user