Skip to content

Commit 3d7a039

Browse files
committed
integrated secret mgt into the gh aw init flow and updated install.md
1 parent 7fe09a3 commit 3d7a039

File tree

4 files changed

+64
-10
lines changed

4 files changed

+64
-10
lines changed

.github/aw/github-agentic-workflows.md

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ curl -sL https://raw.githubusercontent.com/githubnext/gh-aw/main/install-gh-aw.s
8181
Run:
8282

8383
```bash
84-
gh aw init --mcp
84+
gh aw init --mcp --tokens --engine copilot
8585
```
8686

8787
**What this does:**
@@ -90,6 +90,7 @@ gh aw init --mcp
9090
- ✅ Creates `.github/aw/github-agentic-workflows.md` with comprehensive gh-aw documentation
9191
- ✅ Creates `.github/agents/*.agent.md` files with specialized AI assistants for workflow creation and debugging
9292
- ✅ Updates copilot setup steps to install the gh aw extension and setup the Agentic Workflows MCP server
93+
- ✅ Validates which secrets are configured and shows commands to set up missing ones
9394
- ✅ Prepares your repository structure for agentic workflows
9495

9596
**Expected output:**
@@ -99,13 +100,26 @@ gh aw init --mcp
99100
✓ Created .github/aw/github-agentic-workflows.md
100101
✓ Created .github/agents/create-agentic-workflow.agent.md
101102
✓ Created .github/agents/debug-agentic-workflow.agent.md
103+
104+
ℹ Checking recommended gh-aw token secrets in <your-repo>...
105+
ℹ Checking tokens for engine: copilot
106+
✗ Required gh-aw token secrets are missing:
107+
108+
ℹ Secret: COPILOT_GITHUB_TOKEN
109+
ℹ When needed: Copilot workflows (CLI, engine, agent tasks, etc.)
110+
ℹ Recommended scopes: PAT with Copilot Requests permission and repo access
111+
⚡ gh aw secret set COPILOT_GITHUB_TOKEN --owner <owner> --repo <repo>
112+
113+
✓ Repository initialized for agentic workflows!
102114
```
103115

104-
**✨ Checkpoint:** Verify that `.github/aw/` and `.github/agents/` directories were created with the files listed above.
116+
**✨ Checkpoint:** Verify that `.github/aw/` and `.github/agents/` directories were created with the files listed above. If you see missing secrets listed, continue to Step 3 to configure them.
105117

106-
## Step 3: Configure AI Engine (GitHub Copilot)
118+
## Step 3: Configure Missing Secrets
107119

108-
Agentic workflows use AI agents to execute your instructions. The default engine is **GitHub Copilot CLI**.
120+
If the `gh aw init` command showed missing secrets, you'll need to add them to your repository.
121+
122+
### For GitHub Copilot Engine (COPILOT_GITHUB_TOKEN)
109123

110124
### Prerequisites
111125

@@ -141,7 +155,14 @@ Agentic workflows use AI agents to execute your instructions. The default engine
141155

142156
**⚠️ Security Warning:** Never paste your token in this chat or commit it to your repository.
143157

144-
Add the token to your repository using the GitHub.com user interface:
158+
Use the new `gh aw secret set` command to add the token securely:
159+
160+
```bash
161+
# You'll be prompted to enter the token value via stdin
162+
gh aw secret set COPILOT_GITHUB_TOKEN --owner <your-org> --repo <your-repo>
163+
```
164+
165+
Or add it via the GitHub.com interface:
145166

146167
1. Navigate to your repository on GitHub.com
147168
2. Click **Settings** (in the repository menu)
@@ -153,7 +174,13 @@ Add the token to your repository using the GitHub.com user interface:
153174

154175
**Expected result:** You should see `COPILOT_GITHUB_TOKEN` listed in your repository secrets.
155176

156-
**✨ Checkpoint:** Verify the secret was added by checking the Actions secrets page in your repository settings.
177+
**✨ Checkpoint:** Verify the secret was added by running:
178+
179+
```bash
180+
gh aw tokens bootstrap --engine copilot
181+
```
182+
183+
This should now show that all required secrets are present.
157184

158185
**📚 Reference:** [GitHub Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli)
159186

pkg/cli/init.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
var initLog = logger.New("cli:init")
1313

1414
// InitRepository initializes the repository for agentic workflows
15-
func InitRepository(verbose bool, mcp bool, campaign bool, codespaceRepos []string, codespaceEnabled bool) error {
15+
func InitRepository(verbose bool, mcp bool, campaign bool, tokens bool, engine string, codespaceRepos []string, codespaceEnabled bool) error {
1616
initLog.Print("Starting repository initialization for agentic workflows")
1717

1818
// Ensure we're in a git repository
@@ -138,6 +138,20 @@ func InitRepository(verbose bool, mcp bool, campaign bool, codespaceRepos []stri
138138
}
139139
}
140140

141+
// Validate tokens if requested
142+
if tokens {
143+
initLog.Print("Validating repository secrets for agentic workflows")
144+
fmt.Fprintln(os.Stderr, "")
145+
146+
// Run token bootstrap validation
147+
if err := runTokensBootstrap(engine, "", ""); err != nil {
148+
initLog.Printf("Token validation failed: %v", err)
149+
// Don't fail init if token validation has issues
150+
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Token validation encountered an issue: %v", err)))
151+
}
152+
fmt.Fprintln(os.Stderr, "")
153+
}
154+
141155
initLog.Print("Repository initialization completed successfully")
142156

143157
// Display success message with next steps
@@ -152,6 +166,10 @@ func InitRepository(verbose bool, mcp bool, campaign bool, codespaceRepos []stri
152166
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("GitHub Codespaces devcontainer configured"))
153167
fmt.Fprintln(os.Stderr, "")
154168
}
169+
if tokens {
170+
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("To configure missing secrets, use: gh aw secret set <secret-name> --owner <owner> --repo <repo>"))
171+
fmt.Fprintln(os.Stderr, "")
172+
}
155173
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("To create a workflow, launch Copilot CLI: npx @github/copilot"))
156174
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Then type /agent and select create-agentic-workflow"))
157175
fmt.Fprintln(os.Stderr, "")

pkg/cli/init_command.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ This command:
2525
- Creates the debug agentic workflow agent at .github/agents/debug-agentic-workflow.agent.md
2626
- Removes old prompt files from .github/prompts/ if they exist
2727
28+
With --tokens flag:
29+
- Validates which required and optional secrets are configured
30+
- Provides commands to set up missing secrets for the specified engine
31+
- Use with --engine flag to check engine-specific tokens (copilot, claude, codex)
32+
2833
With --mcp flag:
2934
- Creates .github/workflows/copilot-setup-steps.yml with gh-aw installation steps
3035
- Creates .vscode/mcp.json with gh-aw MCP server configuration
@@ -50,12 +55,15 @@ Examples:
5055
` + constants.CLIExtensionPrefix + ` init
5156
` + constants.CLIExtensionPrefix + ` init -v
5257
` + constants.CLIExtensionPrefix + ` init --mcp
58+
` + constants.CLIExtensionPrefix + ` init --tokens --engine copilot
5359
` + constants.CLIExtensionPrefix + ` init --codespaces
5460
` + constants.CLIExtensionPrefix + ` init --codespaces repo1,repo2`,
5561
RunE: func(cmd *cobra.Command, args []string) error {
5662
verbose, _ := cmd.Flags().GetBool("verbose")
5763
mcp, _ := cmd.Flags().GetBool("mcp")
5864
campaign, _ := cmd.Flags().GetBool("campaign")
65+
tokens, _ := cmd.Flags().GetBool("tokens")
66+
engine, _ := cmd.Flags().GetString("engine")
5967
codespaceReposStr, _ := cmd.Flags().GetString("codespaces")
6068
codespaceEnabled := cmd.Flags().Changed("codespaces")
6169

@@ -72,8 +80,8 @@ Examples:
7280
}
7381
}
7482

75-
initCommandLog.Printf("Executing init command: verbose=%v, mcp=%v, campaign=%v, codespaces=%v, codespaceEnabled=%v", verbose, mcp, campaign, codespaceRepos, codespaceEnabled)
76-
if err := InitRepository(verbose, mcp, campaign, codespaceRepos, codespaceEnabled); err != nil {
83+
initCommandLog.Printf("Executing init command: verbose=%v, mcp=%v, campaign=%v, tokens=%v, engine=%v, codespaces=%v, codespaceEnabled=%v", verbose, mcp, campaign, tokens, engine, codespaceRepos, codespaceEnabled)
84+
if err := InitRepository(verbose, mcp, campaign, tokens, engine, codespaceRepos, codespaceEnabled); err != nil {
7785
initCommandLog.Printf("Init command failed: %v", err)
7886
return err
7987
}
@@ -84,6 +92,8 @@ Examples:
8492

8593
cmd.Flags().Bool("mcp", false, "Configure GitHub Copilot Agent MCP server integration")
8694
cmd.Flags().Bool("campaign", false, "Install the Campaign Designer agent for gh-aw campaigns in this repository")
95+
cmd.Flags().Bool("tokens", false, "Validate required secrets for agentic workflows")
96+
cmd.Flags().String("engine", "", "AI engine to check tokens for (copilot, claude, codex) - requires --tokens flag")
8797
cmd.Flags().String("codespaces", "", "Create devcontainer.json for GitHub Codespaces with agentic workflows support. Specify comma-separated repository names in the same organization (e.g., repo1,repo2), or use without value for current repo only")
8898
// NoOptDefVal allows using --codespaces without a value (returns empty string when no value provided)
8999
cmd.Flags().Lookup("codespaces").NoOptDefVal = " "

0 commit comments

Comments
 (0)