Add Claude

This commit is contained in:
2026-07-18 02:25:09 +09:00
parent 4a4b3b9538
commit 5039c728cb
3 changed files with 57 additions and 8 deletions
+14 -6
View File
@@ -1,9 +1,16 @@
name: Codex Bot name: Bot agents
description: Run Codex CLI for approved Gitea issue/PR automation description: Run a coding agent for approved Gitea issue/PR automation
inputs: inputs:
gitea-token: bot-type:
description: Which bot to run, either `codex` or `claude`
required: true required: true
gitea-token:
description: Gitea access token for API calls and pushes
required: true
bot-token:
description: API key or token for the selected bot
required: false
runs: runs:
using: composite using: composite
@@ -14,15 +21,16 @@ runs:
run: | run: |
apt-get update apt-get update
apt-get install -y --no-install-recommends gettext-base jq ansifilter apt-get install -y --no-install-recommends gettext-base jq ansifilter
npm install -g @openai/codex npm install -g @openai/codex @anthropic-ai/claude-code
- name: Run Codex - name: Run bot
shell: bash shell: bash
run: bash "${ACTION_PATH}/scripts/run-codex.sh" run: bash "${ACTION_PATH}/scripts/run-${{ inputs.bot-type }}.sh"
env: env:
ACTION_PATH: ${{ gitea.action_path }} ACTION_PATH: ${{ gitea.action_path }}
GITEA_API_URL: ${{ gitea.api_url }} GITEA_API_URL: ${{ gitea.api_url }}
GITEA_REPOSITORY: ${{ gitea.repository }} GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_TOKEN: ${{ inputs.gitea-token }} GITEA_TOKEN: ${{ inputs.gitea-token }}
BOT_TOKEN: ${{ inputs.bot-token }}
EVENT_NAME: ${{ gitea.event_name }} EVENT_NAME: ${{ gitea.event_name }}
ISSUE_INDEX: ${{ gitea.event.issue.number || gitea.event.pull_request.number }} ISSUE_INDEX: ${{ gitea.event.issue.number || gitea.event.pull_request.number }}
COMMENT: ${{ toJSON(gitea.event.comment || gitea.event.review) }} COMMENT: ${{ toJSON(gitea.event.comment || gitea.event.review) }}
+2 -2
View File
@@ -1,4 +1,4 @@
You are Codex running inside Gitea Actions. You are a coding agent running inside Gitea Actions.
Do not post a final issue comment yourself; your final response is posted Do not post a final issue comment yourself; your final response is posted
automatically. Post additional comments only when needed for PR updates, automatically. Post additional comments only when needed for PR updates,
@@ -29,7 +29,7 @@ latest branch state before pushing. Skip this check when no code changes are
needed. needed.
Prefer minimal, correct changes. Run relevant checks or tests if practical. Prefer minimal, correct changes. Run relevant checks or tests if practical.
Treat code changes as a request to create a pull request. If a prior Codex pull Treat code changes as a request to create a pull request. If a prior bot pull
request already exists for this issue, update that same pull request instead of request already exists for this issue, update that same pull request instead of
creating a new one. When you create a pull request, include `@bot` in its body creating a new one. When you create a pull request, include `@bot` in its body
and ask it to review the pull request. This is required for every pull request and ask it to review the pull request. This is required for every pull request
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
git config --global user.name bot
git config --global user.email noreply@capsulizers.com
COMMENT_FILE="$(mktemp)"
post_comment() {
COMMENT_JSON="$(jq -n --rawfile body "${COMMENT_FILE}" '{body: $body}')"
curl --fail-with-body --silent --show-error \
-X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
--data "${COMMENT_JSON}" \
"${GITEA_API_URL}/repos/${GITEA_REPOSITORY}/issues/${ISSUE_INDEX}/comments"
}
if [ -z "${BOT_TOKEN:-}" ]; then
echo 'Run `claude setup-token` locally and set the `bot-token` action input.' > "${COMMENT_FILE}"
post_comment
exit 1
fi
export CLAUDE_CODE_OAUTH_TOKEN="${BOT_TOKEN}"
export ISSUE_COMMENTS="$(
curl --fail-with-body --silent --show-error \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_API_URL}/repos/${GITEA_REPOSITORY}/issues/${ISSUE_INDEX}/comments?limit=100" \
| jq -r '.[] | "## " + .user.login + " at " + .created_at + "\n\n" + .body + "\n"'
)"
FINAL_PROMPT="$(envsubst < "${ACTION_PATH}/scripts/prompt.md")"
# Claude refuses --dangerously-skip-permissions as root outside a sandbox.
export IS_SANDBOX=1
claude --print --dangerously-skip-permissions "${FINAL_PROMPT}" \
| ansifilter > "${COMMENT_FILE}"
post_comment