From 34b677f43b9846c2caa9f195f9ba5b583f4bf551 Mon Sep 17 00:00:00 2001 From: MervinPraison Date: Sun, 15 Jun 2025 06:43:34 +0100 Subject: [PATCH] Enhance Claude Code action by adding environment variable verification and updating Docker setup for improved reliability --- .github/actions/claude-code-action/action.yml | 3 +++ .github/actions/claude-code-action/entrypoint.sh | 12 +++++++++--- .github/workflows/claude.yml | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/actions/claude-code-action/action.yml b/.github/actions/claude-code-action/action.yml index 368183dc9..87d2ca42b 100644 --- a/.github/actions/claude-code-action/action.yml +++ b/.github/actions/claude-code-action/action.yml @@ -12,6 +12,9 @@ inputs: runs: using: "docker" image: "ghcr.io/mervinpraison/praisonai-claudecode:latest" + env: + ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }} + GITHUB_TOKEN: ${{ inputs.github_token }} args: - "--anthropic-api-key=${{ inputs.anthropic_api_key }}" - "--github-token=${{ inputs.github_token }}" \ No newline at end of file diff --git a/.github/actions/claude-code-action/entrypoint.sh b/.github/actions/claude-code-action/entrypoint.sh index ca2af4fbd..9eec6e832 100644 --- a/.github/actions/claude-code-action/entrypoint.sh +++ b/.github/actions/claude-code-action/entrypoint.sh @@ -7,9 +7,15 @@ echo "Running Claude Code in CI mode..." # Extract GitHub context and create a smart prompt PROMPT="Analyse the GitHub issue or PR context and generate a smart response based on the repository context." -# Set environment variables -export ANTHROPIC_API_KEY="$1" -export GITHUB_TOKEN="$2" +# Set environment variables from arguments +export ANTHROPIC_API_KEY="${1#--anthropic-api-key=}" +export GITHUB_TOKEN="${2#--github-token=}" + +# Verify environment variables +if [ -z "$ANTHROPIC_API_KEY" ] || [ -z "$GITHUB_TOKEN" ]; then + echo "Error: Required environment variables are not set" + exit 1 +fi # Run Claude with the prompt claude -p "$PROMPT" \ No newline at end of file diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 1ab317e0c..19ce9ac2f 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -30,11 +30,14 @@ jobs: with: fetch-depth: 1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: MervinPraison password: ${{ secrets.GH_TOKEN }} - name: Run Claude Code