diff --git a/scripts/runtime/claudecode-entrypoint.sh b/scripts/runtime/claudecode-entrypoint.sh index 3dc7d05..43742a8 100755 --- a/scripts/runtime/claudecode-entrypoint.sh +++ b/scripts/runtime/claudecode-entrypoint.sh @@ -53,22 +53,22 @@ else echo "WARNING: No Claude authentication source found at /home/node/.claude." >&2 fi -# Configure GitHub authentication -if [ -n "${GITHUB_TOKEN}" ]; then - export GH_TOKEN="${GITHUB_TOKEN}" - echo "${GITHUB_TOKEN}" | sudo -u node gh auth login --with-token - sudo -u node gh auth setup-git +# Configure Gitea authentication +if [ -n "${GITEA_TOKEN}" ] && [ -n "${GITEA_API_URL}" ]; then + GIT_HOST=$(echo "${GITEA_API_URL}" | sed -E 's|https?://([^/]+).*|\1|') + echo "Using Gitea token for ${GIT_HOST}" >&2 else - echo "No GitHub token provided, skipping GitHub authentication" + echo "No Gitea token provided, skipping Git authentication" >&2 + GIT_HOST="" fi # Clone the repository as node user -if [ -n "${GITHUB_TOKEN}" ] && [ -n "${REPO_FULL_NAME}" ]; then - echo "Cloning repository ${REPO_FULL_NAME}..." >&2 - sudo -u node git clone "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO_FULL_NAME}.git" /workspace/repo >&2 +if [ -n "${GITEA_TOKEN}" ] && [ -n "${REPO_FULL_NAME}" ] && [ -n "${GIT_HOST}" ]; then + echo "Cloning repository ${REPO_FULL_NAME} from ${GIT_HOST}..." >&2 + sudo -u node git clone "https://ClaudeBot:${GITEA_TOKEN}@${GIT_HOST}/${REPO_FULL_NAME}.git" /workspace/repo >&2 cd /workspace/repo else - echo "Skipping repository clone - missing GitHub token or repository name" >&2 + echo "Skipping repository clone - missing token or repository name" >&2 cd /workspace fi diff --git a/src/services/claudeService.ts b/src/services/claudeService.ts index 784f18b..2ce59b1 100644 --- a/src/services/claudeService.ts +++ b/src/services/claudeService.ts @@ -347,6 +347,7 @@ function createEnvironmentVars({ OPERATION_TYPE: operationType, COMMAND: fullPrompt, GITEA_TOKEN: giteaToken, + GITEA_API_URL: process.env.GITEA_API_URL ?? '', ANTHROPIC_API_KEY: secureCredentials.get('ANTHROPIC_API_KEY') ?? '', BOT_USERNAME: process.env.BOT_USERNAME, BOT_EMAIL: process.env.BOT_EMAIL