-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enhance Claude Code action by adding environment variable verificatio… #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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=}" | ||||||
|
Comment on lines
+11
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If The script could directly use This change is contingent on removing these secrets from the |
||||||
|
|
||||||
| # Verify environment variables | ||||||
| if [ -z "$ANTHROPIC_API_KEY" ] || [ -z "$GITHUB_TOKEN" ]; then | ||||||
| echo "Error: Required environment variables are not set" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message here is a bit generic. To improve debuggability, consider making it more specific about which environment variables are missing.
Suggested change
|
||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| # Run Claude with the prompt | ||||||
| claude -p "$PROMPT" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of the
envblock (lines 15-17) is a good practice for passing secrets like API keys to the Docker container. WithANTHROPIC_API_KEYandGITHUB_TOKENnow being set as environment variables for the Docker container, you might consider removing them from theargssection (currently on lines 19-20).Benefits of this change would be:
If these arguments are removed, the
entrypoint.shscript should be updated to directly use these environment variables rather than parsing them from script arguments.