@@ -23,6 +23,13 @@ pub enum GitHubSubcommand {
2323 Install ( InstallArgs ) ,
2424
2525 /// Run GitHub agent in Actions context.
26+ ///
27+ /// This command is designed to be called from within a GitHub Actions workflow.
28+ /// It processes GitHub events (issues, pull requests, comments) and responds
29+ /// automatically using the Cortex AI agent.
30+ ///
31+ /// Typically, you don't run this command manually. Instead, use `cortex github install`
32+ /// to set up the workflow that will call this command automatically.
2633 Run ( RunArgs ) ,
2734
2835 /// Check GitHub Actions installation status.
@@ -55,25 +62,61 @@ pub struct InstallArgs {
5562
5663/// Arguments for run command.
5764#[ derive( Debug , Parser ) ]
65+ #[ command(
66+ about = "Run GitHub agent in Actions context" ,
67+ long_about = "Run GitHub agent in Actions context.\n \n \
68+ This command is designed to be called from within a GitHub Actions workflow. \
69+ It processes GitHub events (issues, pull requests, comments) and responds \
70+ automatically using the Cortex AI agent.\n \n \
71+ USAGE:\n \
72+ Typically, you don't run this command manually. Use `cortex github install` \
73+ to set up the workflow that will call this command automatically.\n \n \
74+ ENVIRONMENT VARIABLES:\n \
75+ The following environment variables are automatically set by GitHub Actions:\n \
76+ GITHUB_TOKEN - Token for GitHub API access (required)\n \
77+ GITHUB_EVENT_PATH - Path to the event payload JSON file (required)\n \
78+ GITHUB_REPOSITORY - Repository in owner/repo format (required)\n \
79+ GITHUB_RUN_ID - The workflow run ID (optional)\n \n \
80+ EXAMPLES:\n \
81+ # Typical invocation from a GitHub Actions workflow:\n \
82+ cortex github run --event ${{ github.event_name }} \\ \n \
83+ --token ${{ secrets.GITHUB_TOKEN }} \\ \n \
84+ --event-path ${{ github.event_path }} \\ \n \
85+ --repository ${{ github.repository }}\n \n \
86+ # Test locally with a dry run:\n \
87+ cortex github run --event issue_comment \\ \n \
88+ --token ghp_xxxx \\ \n \
89+ --event-path ./event.json \\ \n \
90+ --repository owner/repo \\ \n \
91+ --dry-run\n \n \
92+ SUPPORTED EVENTS:\n \
93+ issue_comment - Triggered on issue or PR comments\n \
94+ pull_request - Triggered on PR open, sync, or reopen\n \
95+ pull_request_review - Triggered on PR review submission\n \
96+ issues - Triggered when issues are opened\n \n \
97+ SEE ALSO:\n \
98+ cortex github install - Install the workflow file\n \
99+ cortex github status - Check installation status"
100+ ) ]
58101pub struct RunArgs {
59102 /// GitHub event type.
60103 #[ arg( long, short, value_parser = clap:: builder:: PossibleValuesParser :: new( [ "issue_comment" , "pull_request" , "pull_request_review" , "issues" ] ) ) ]
61104 pub event : String ,
62105
63- /// GitHub token for API access.
64- #[ arg( long, short) ]
106+ /// GitHub token for API access (or set GITHUB_TOKEN env var) .
107+ #[ arg( long, short, env = "GITHUB_TOKEN" ) ]
65108 pub token : Option < String > ,
66109
67- /// Path to the event payload JSON file.
68- #[ arg( long) ]
110+ /// Path to the event payload JSON file (or set GITHUB_EVENT_PATH env var) .
111+ #[ arg( long, env = "GITHUB_EVENT_PATH" ) ]
69112 pub event_path : Option < PathBuf > ,
70113
71- /// GitHub repository ( owner/repo format).
72- #[ arg( long) ]
114+ /// GitHub repository in owner/repo format (or set GITHUB_REPOSITORY env var ).
115+ #[ arg( long, env = "GITHUB_REPOSITORY" ) ]
73116 pub repository : Option < String > ,
74117
75- /// GitHub run ID.
76- #[ arg( long) ]
118+ /// GitHub workflow run ID (or set GITHUB_RUN_ID env var) .
119+ #[ arg( long, env = "GITHUB_RUN_ID" ) ]
77120 pub run_id : Option < String > ,
78121
79122 /// Dry run mode - don't execute, just show what would happen.
0 commit comments