Skip to content

Add ambient-action workflow#10

Merged
jeremyeder merged 2 commits intomainfrom
add-ambient-action
Mar 26, 2026
Merged

Add ambient-action workflow#10
jeremyeder merged 2 commits intomainfrom
add-ambient-action

Conversation

@jeremyeder
Copy link
Copy Markdown
Contributor

Summary

  • Adds .github/workflows/ambient.yml triggered by @ambient issue comments
  • Creates ACP sessions (fire-and-forget) to auto-fix issues on feature branches
  • Restricted to org members (OWNER/MEMBER author association)
  • Requires AMBIENT_API_URL and AMBIENT_BOT_TOKEN secrets (already configured)

Test plan

  • Merge to main
  • Comment @ambient describe what this repo does on a test issue
  • Verify session appears in ACP UI under project gps-ambient-action

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Adds a new GitHub Actions workflow that triggers on created issue comments. If the comment starts with @ambient and the commenter’s author_association is OWNER or MEMBER, it runs ambient-code/ambient-action@v2, passing secret-backed api-url and api-token, a fixed project value, the comment body as prompt, a display-name including the issue number, repo config targeting branch ambient/issue-<issue_number> with autoPush: true, and labels as a JSON string containing the issue number.

Changes

Cohort / File(s) Summary
GitHub Actions workflow
​.github/workflows/ambient.yml
Adds a new workflow listening for issue_comment created events. Job guarded by if requiring comment body to start with @ambient and author_association in (OWNER,MEMBER). Runs ambient-code/ambient-action@v2 with secret inputs api-url/api-token, fixed project, prompt (full comment body), display-name (includes issue number), repo config using branch ambient/issue-<issue_number> and autoPush: true, and labels JSON containing the issue number.

Sequence Diagram(s)

sequenceDiagram
  participant User as Commenter
  participant GH as GitHub
  participant Runner as Actions Runner
  participant Action as ambient-action
  participant API as External API

  User->>GH: Post issue comment starting with "@ambient"
  GH->>Runner: Trigger workflow (issue_comment: created)
  Runner->>Runner: Evaluate `if` (comment startsWith "@ambient" && author_association in OWNER,MEMBER)
  Runner->>Action: Execute ambient-code/ambient-action@v2 with inputs (prompt, project, display-name, repo config, labels) and secrets (api-url, api-token)
  Action->>API: Send prompt + repo/context via API_URL/API_TOKEN
  API-->>Action: Return response
  Action-->>Runner: Finish job (may push branch `ambient/issue-<issue_number>`)
  Runner-->>GH: Record workflow run result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a new GitHub Actions workflow for the ambient-action integration.
Description check ✅ Passed The description clearly relates to the changeset, explaining the workflow's purpose, trigger mechanism, restrictions, and test plan for the ambient-action feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-ambient-action

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ambient.yml:
- Line 21: The workflow currently hardcodes the repos JSON with "branch": "main"
while "autoPush": true, which risks pushing fixes directly to the default
branch; update the JSON so pushes target the PR/feature branch instead (or
disable autoPush). Specifically, replace the fixed "branch": "main" with a
branch expression that points to the feature/PR head (for example use the
workflow/runner variable referencing the head ref) or set "autoPush": false;
adjust the "repos" value that contains the "branch" and "autoPush" keys so the
action pushes only to the intended feature branch (or not at all).
- Around line 9-11: The current workflow condition uses startsWith(...) and
contains(...) on github.event.comment but does not prevent firing for PR
discussion comments; update the condition to also check that
github.event.issue.pull_request is null (i.e., add an additional guard alongside
the existing startsWith(...) and contains(...) checks) so the job only runs for
issue comments and not pull request conversation comments.
- Around line 7-13: Add an explicit permissions block to the ambient job to
restrict GITHUB_TOKEN scopes instead of using defaults: inside the job named
ambient (under jobs -> ambient) declare a permissions mapping for the workflow
or the job that grants only the minimum required scopes (for example read:
contents, write: issues, or whichever specific permissions your commands need)
and remove reliance on default broad permissions; ensure the permission keys
match GitHub Actions syntax (permissions: { <scope>: <read|write|none> }) so the
ambient job uses only least-privilege access.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2b1ab5fc-784f-4068-877d-fd2edfccc304

📥 Commits

Reviewing files that changed from the base of the PR and between 4717397 and ccef394.

📒 Files selected for processing (1)
  • .github/workflows/ambient.yml

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
.github/workflows/ambient.yml (2)

24-24: ⚠️ Potential issue | 🔴 Critical

autoPush to main conflicts with the feature-branch objective.

Line 24 sets "branch": "main" with "autoPush": true, which can push bot changes directly to default branch. Target a dedicated feature branch (e.g., per-issue) or disable auto-push.

Safer branch targeting example
-          repos: '[{"url": "https://github.com/${{ github.repository }}", "branch": "main", "autoPush": true}]'
+          repos: '[{"url": "https://github.com/${{ github.repository }}", "branch": "ambient/issue-${{ github.event.issue.number }}", "autoPush": true}]'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ambient.yml at line 24, The workflow currently sets repos:
'[{"url": "https://github.com/${{ github.repository }}", "branch": "main",
"autoPush": true}]' which allows automatic pushes to main; change this to target
a dedicated feature branch (or disable autoPush) by updating the repos entry to
use a non-default branch name pattern (e.g., a per-run or per-issue feature
branch like "ambient-bot/${{ github.run_id }}" or issue-based name) or set
"autoPush": false so the action will not push directly to main; update the
"branch" and/or "autoPush" fields in the repos object accordingly.

12-14: ⚠️ Potential issue | 🟠 Major

Add an issues-only guard to avoid triggering from PR comments.

issue_comment also fires for PR conversation comments. Add github.event.issue.pull_request == null so this runs only on issues (Line 12).

Suggested condition hardening
     if: >-
+      github.event.issue.pull_request == null &&
       startsWith(github.event.comment.body, '@ambient') &&
       contains(fromJSON('["OWNER","MEMBER"]'), github.event.comment.author_association)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ambient.yml around lines 12 - 14, The existing workflow
if-condition (the line with startsWith(github.event.comment.body, '@ambient') &&
contains(fromJSON('["OWNER","MEMBER"]'),
github.event.comment.author_association)) allows PR comment events because
issue_comment also triggers for PRs; update the condition to include a guard for
issues by adding github.event.issue.pull_request == null so the combined if
requires the comment to be on an issue (not a PR) in addition to the existing
startsWith(...) and contains(...) checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/ambient.yml:
- Line 24: The workflow currently sets repos: '[{"url": "https://github.com/${{
github.repository }}", "branch": "main", "autoPush": true}]' which allows
automatic pushes to main; change this to target a dedicated feature branch (or
disable autoPush) by updating the repos entry to use a non-default branch name
pattern (e.g., a per-run or per-issue feature branch like "ambient-bot/${{
github.run_id }}" or issue-based name) or set "autoPush": false so the action
will not push directly to main; update the "branch" and/or "autoPush" fields in
the repos object accordingly.
- Around line 12-14: The existing workflow if-condition (the line with
startsWith(github.event.comment.body, '@ambient') &&
contains(fromJSON('["OWNER","MEMBER"]'),
github.event.comment.author_association)) allows PR comment events because
issue_comment also triggers for PRs; update the condition to include a guard for
issues by adding github.event.issue.pull_request == null so the combined if
requires the comment to be on an issue (not a PR) in addition to the existing
startsWith(...) and contains(...) checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0d67e617-1d03-40b0-a6ac-a4f00826e5aa

📥 Commits

Reviewing files that changed from the base of the PR and between ccef394 and 2da0e16.

📒 Files selected for processing (1)
  • .github/workflows/ambient.yml

Triggers an ACP session when org members comment @ambient on issues.
Restricted to OWNER and MEMBER author associations for security.
Workflow token scoped to contents: read per least-privilege principle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ACP sessions now push to ambient/issue-<number> branches instead of
main, ensuring changes go through PR review before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremyeder
Copy link
Copy Markdown
Contributor Author

Addressing review feedback:

Permissions (CodeQL/CodeRabbit): Already resolved — the squashed commit includes permissions: contents: read at the workflow level (lines 7-8).

Scope to issues only (CodeRabbit): Intentionally kept as-is — per @jeremyeder, this should run on both issues and PRs.

Branch targeting (CodeRabbit): Good catch. Fixed — now targets ambient/issue-<number> branch instead of main, so changes go through PR review.

@jeremyeder
Copy link
Copy Markdown
Contributor Author

I'm merging this with CI failing because this PR has an old copy of the workflow that will never pass. It is fixed in #11

@jeremyeder jeremyeder merged commit 05415b1 into main Mar 26, 2026
5 of 8 checks passed
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.

1 participant