Skip to content

Conversation

@atsushi-ishibashi
Copy link
Contributor

This PR implements the feature requested in #426 to make GitHub asset download functionality available outside of Tag Mode.

Changes:

  • New input parameter: Added download_github_assets (default: false) to action.yml
  • Agent Mode enhancement: Extended Agent Mode to download GitHub images when enabled and running in entity context (issues/PRs)
  • Environment variable: Downloaded file paths are exposed via CLAUDE_ASSET_FILES as comma-separated values
  • Context-aware: Only downloads assets for entity events (issue_comment, pull_request, etc.), not automation events
  • Error handling: Failures don't break the entire action execution

Usage:

- uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    download_github_assets: true
    prompt: |
      Analyze images from this issue/PR.
      Files available in CLAUDE_ASSET_FILES environment variable.

Files changed:

  • action.yml - Added new input parameter
  • src/modes/agent/index.ts - Implemented download functionality
  • examples/agent-with-assets.yml - Added usage example with shell expansion
  • test/modes/agent.test.ts - Added comprehensive tests

This enables Agent Mode workflows to access and analyze GitHub attachments (screenshots, diagrams, etc.) that were previously only available in Tag Mode.

@km-anthropic
Copy link
Collaborator

km-anthropic commented Aug 27, 2025

Found some issue in the example workflow file

The Issue

The implementation sets CLAUDE_ASSET_FILES using process.env which only exists within the current Node.js process and doesn't persist to subsequent GitHub Actions steps. This makes the feature unusable as documented in the example workflow.

How I Tested

Created a test workflow to verify environment variable persistence between steps:

  1. Step 1: Runs the action with download_github_assets: true
  2. Step 2: Checks if CLAUDE_ASSET_FILES is available
  3. Result: ❌ Variable is empty in the next step

Test run: https://github.com/km-anthropic/claude-code-action/actions/runs/17262284603

Test Output

=== Checking CLAUDE_ASSET_FILES availability ===
CLAUDE_ASSET_FILES value: ''
❌ BUG CONFIRMED: CLAUDE_ASSET_FILES is empty!
The environment variable set by process.env doesn't persist between steps

The Problem Code

In src/modes/agent/index.ts line 144:

process.env.CLAUDE_ASSET_FILES = downloadedPaths.join(",");

This only sets the variable for the current process, not for subsequent workflow steps.

The Fix

Replace line 144 with one of these options:

Option 1: Use GitHub Actions core (recommended)

core.exportVariable('CLAUDE_ASSET_FILES', downloadedPaths.join(','));

Option 2: Write to GITHUB_ENV file

const githubEnvFile = process.env.GITHUB_ENV;
if (githubEnvFile) {
  require('fs').appendFileSync(
    githubEnvFile,
    `CLAUDE_ASSET_FILES=${downloadedPaths.join(",")}\n`
  );
}

Impact

Without this fix:

  • The example workflow in examples/agent-with-assets.yml won't work
  • Step 2 can't access the downloaded asset paths from Step 1
  • The feature is effectively broken for multi-step workflows

The asset downloading itself works correctly - the issue is only with making the paths available to subsequent steps.

Test Workflow Used

You can see the test workflow here: https://github.com/km-anthropic/claude-code-action/blob/main/.github/workflows/test-asset-env.yml

cc @atsushi-ishibashi - this needs to be fixed before merging, as the feature won't work as documented without this change.

@atsushi-ishibashi
Copy link
Contributor Author

@km-anthropic Fixed with Option1👍️

@km-anthropic
Copy link
Collaborator

Thanks! Can you update usage.md too! then we should be good to go

@atsushi-ishibashi
Copy link
Contributor Author

@km-anthropic
I wrote the example yml just to give you an idea, but should I leave it as is? Since its level of detail is different from the other examples, I was thinking of deleting it.

@km-anthropic
Copy link
Collaborator

@km-anthropic I wrote the example yml just to give you an idea, but should I leave it as is? Since its level of detail is different from the other examples, I was thinking of deleting it.

Yeah I think that's fine, ideally a simpler and cleaner example would be great if you can do it.

@atsushi-ishibashi
Copy link
Contributor Author

@km-anthropic
Update usage.md and simplify the example GitHub Actions workflow.

km-anthropic
km-anthropic previously approved these changes Aug 27, 2025
action.yml Outdated
Comment on lines 30 to 33
download_github_assets:
description: "Download GitHub assets (images, attachments) for access via environment variables"
required: false
default: "false"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be an input? Feels like we can do it by default without much issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashwin-ant
Since file download overhead could affect GitHub Actions runtime, I added an input to disable file downloads by default in agent mode. That said, I think it would also be fine to perform downloads by default. (If it seems possible to speed up the download process, I might try that in a separate PR.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to just make it happen automatically given that most issues and PRs don't have images anyway. We can add an opt-out later if it becomes necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While writing usage.md, I also felt that it’s somewhat confusing that this input only works in agent mode, whereas in tag mode downloads occur regardless of its value. Moreover, since the mode is now auto-detected, this distinction seems even less clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to just make it happen automatically given that most issues and PRs don't have images anyway. We can add an opt-out later if it becomes necessary.

Sure👍️ I'll remove the input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashwin-ant resolved!

Copy link
Collaborator

@km-anthropic km-anthropic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me! Can you please update the docs, usage.md in specific?

@atsushi-ishibashi
Copy link
Contributor Author

Generally looks good to me! Can you please update the docs, usage.md in specific?

@km-anthropic
Are you suggesting that we should delete examples/agent-with-assets.yml and move its contents into usage.md?

@xFlaviews
Copy link

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants