Skip to content

Commit 34b677f

Browse files
committed
Enhance Claude Code action by adding environment variable verification and updating Docker setup for improved reliability
1 parent b4831b3 commit 34b677f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.github/actions/claude-code-action/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ inputs:
1212
runs:
1313
using: "docker"
1414
image: "ghcr.io/mervinpraison/praisonai-claudecode:latest"
15+
env:
16+
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
17+
GITHUB_TOKEN: ${{ inputs.github_token }}
1518
args:
1619
- "--anthropic-api-key=${{ inputs.anthropic_api_key }}"
1720
- "--github-token=${{ inputs.github_token }}"

.github/actions/claude-code-action/entrypoint.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ echo "Running Claude Code in CI mode..."
77
# Extract GitHub context and create a smart prompt
88
PROMPT="Analyse the GitHub issue or PR context and generate a smart response based on the repository context."
99

10-
# Set environment variables
11-
export ANTHROPIC_API_KEY="$1"
12-
export GITHUB_TOKEN="$2"
10+
# Set environment variables from arguments
11+
export ANTHROPIC_API_KEY="${1#--anthropic-api-key=}"
12+
export GITHUB_TOKEN="${2#--github-token=}"
13+
14+
# Verify environment variables
15+
if [ -z "$ANTHROPIC_API_KEY" ] || [ -z "$GITHUB_TOKEN" ]; then
16+
echo "Error: Required environment variables are not set"
17+
exit 1
18+
fi
1319

1420
# Run Claude with the prompt
1521
claude -p "$PROMPT"

.github/workflows/claude.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ jobs:
3030
with:
3131
fetch-depth: 1
3232

33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
3336
- name: Login to GitHub Container Registry
3437
uses: docker/login-action@v3
3538
with:
3639
registry: ghcr.io
37-
username: ${{ github.actor }}
40+
username: MervinPraison
3841
password: ${{ secrets.GH_TOKEN }}
3942

4043
- name: Run Claude Code

0 commit comments

Comments
 (0)