Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/issue-classifier.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .github/workflows/poem-bot.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions actions/setup/js/create_agent_session.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ async function main() {
const baseBranch = process.env.GITHUB_AW_AGENT_SESSION_BASE || process.env.GITHUB_REF_NAME || "main";
const targetRepo = process.env.GITHUB_AW_TARGET_REPO;

// Get GH_TOKEN for gh CLI authentication
const ghToken = process.env.GH_TOKEN;
if (!ghToken) {
core.setFailed("GH_TOKEN environment variable is required for gh CLI authentication");
return;
}

// Process all agent session items
const createdTasks = [];
let summaryContent = "## ✅ Agent Sessions Created\n\n";
Expand Down Expand Up @@ -119,6 +126,7 @@ async function main() {
taskOutput = await exec.getExecOutput("gh", ghArgs, {
silent: false,
ignoreReturnCode: false,
env: { ...process.env, GH_TOKEN: ghToken },
});
} catch (execError) {
const errorMessage = execError instanceof Error ? execError.message : String(execError);
Expand Down
17 changes: 17 additions & 0 deletions pkg/workflow/compiler_safe_outputs_specialized.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ func (c *Compiler) buildCreateAgentSessionStepConfig(data *WorkflowData, mainJob
var customEnvVars []string
customEnvVars = append(customEnvVars, c.buildStepLevelSafeOutputEnvVars(data, "")...)

// Add GH_TOKEN environment variable for gh CLI authentication
// Get the safe-outputs token (if configured) or use top-level token
var safeOutputsToken string
if data.SafeOutputs != nil {
safeOutputsToken = data.SafeOutputs.GitHubToken
}
// Use Copilot token chain: customToken > safeOutputsToken > data.GitHubToken > COPILOT_GITHUB_TOKEN || GH_AW_GITHUB_TOKEN
effectiveToken := getEffectiveCopilotGitHubToken(cfg.GitHubToken, getEffectiveCopilotGitHubToken(safeOutputsToken, data.GitHubToken))
customEnvVars = append(customEnvVars, fmt.Sprintf(" GH_TOKEN: %s\n", effectiveToken))

// Add GITHUB_AW_AGENT_SESSION_BASE environment variable
if cfg.Base != "" {
customEnvVars = append(customEnvVars, fmt.Sprintf(" GITHUB_AW_AGENT_SESSION_BASE: %q\n", cfg.Base))
} else {
customEnvVars = append(customEnvVars, " GITHUB_AW_AGENT_SESSION_BASE: ${{ github.ref_name }}\n")
}

condition := BuildSafeOutputType("create_agent_session")

return SafeOutputStepConfig{
Expand Down