-
Notifications
You must be signed in to change notification settings - Fork 4
feat: implement new github app #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
derekmisler
merged 1 commit into
docker:main
from
derekmisler:feature-implement-new-github-app
Feb 4, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| # Reusable workflow for AI-powered PR reviews | ||
| # Usage: | ||
| # name: PR Review | ||
| # on: | ||
| # issue_comment: | ||
| # types: [created] | ||
| # pull_request_review_comment: | ||
| # types: [created] | ||
| # pull_request_target: | ||
| # types: [ready_for_review, opened] | ||
| # | ||
| # permissions: | ||
| # contents: read | ||
| # pull-requests: write | ||
| # issues: write | ||
| # | ||
| # jobs: | ||
| # review: | ||
| # uses: docker/cagent-action/.github/workflows/review-pr.yml@latest | ||
| # secrets: inherit | ||
|
|
||
| name: PR Review | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pr-number: | ||
| description: "Pull request number (auto-detected if not provided)" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| comment-id: | ||
| description: "Comment ID for reactions (auto-detected if not provided)" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| additional-prompt: | ||
| description: "Additional instructions for the review" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| model: | ||
| description: "Model to use (e.g., anthropic/claude-sonnet-4-5)" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| cagent-version: | ||
| description: "Version of cagent to use" | ||
| required: false | ||
| type: string | ||
| default: "v1.19.7" | ||
| auto-review-org: | ||
| description: "Organization to check membership for auto-reviews" | ||
| required: false | ||
| type: string | ||
| default: "docker" | ||
| secrets: | ||
| ORG_MEMBERSHIP_TOKEN: | ||
| description: "PAT with read:org scope to check org membership for auto-reviews" | ||
| required: false | ||
| ANTHROPIC_API_KEY: | ||
| description: "Anthropic API key (at least one API key required)" | ||
| required: false | ||
| OPENAI_API_KEY: | ||
| description: "OpenAI API key (at least one API key required)" | ||
| required: false | ||
| GOOGLE_API_KEY: | ||
| description: "Google API key (at least one API key required)" | ||
| required: false | ||
| AWS_BEARER_TOKEN_BEDROCK: | ||
| description: "AWS Bearer token for Bedrock (at least one API key required)" | ||
| required: false | ||
| XAI_API_KEY: | ||
| description: "xAI API key for Grok (at least one API key required)" | ||
| required: false | ||
| NEBIUS_API_KEY: | ||
| description: "Nebius API key (at least one API key required)" | ||
| required: false | ||
| MISTRAL_API_KEY: | ||
| description: "Mistral API key (at least one API key required)" | ||
| required: false | ||
| CAGENT_REVIEWER_APP_ID: | ||
| description: "GitHub App ID for reviewer identity" | ||
| required: false | ||
| CAGENT_REVIEWER_APP_PRIVATE_KEY: | ||
| description: "GitHub App private key" | ||
| required: false | ||
| outputs: | ||
| exit-code: | ||
| description: "Exit code from the review" | ||
| value: ${{ jobs.auto-review.outputs.exit-code || jobs.manual-review.outputs.exit-code }} | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| # ========================================================================== | ||
| # AUTOMATIC REVIEW FOR ORG MEMBERS | ||
| # Triggers when a PR is marked ready for review or opened (non-draft) | ||
| # Only runs for members of the configured org (supports fork-based workflow) | ||
| # ========================================================================== | ||
| auto-review: | ||
| if: | | ||
| github.event_name == 'pull_request_target' && | ||
| !github.event.pull_request.draft | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }} | ||
| outputs: | ||
| exit-code: ${{ steps.run-review.outputs.exit-code }} | ||
|
|
||
| steps: | ||
| - name: Check if PR author is org member | ||
| id: membership | ||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
| with: | ||
| github-token: ${{ secrets.ORG_MEMBERSHIP_TOKEN }} | ||
| script: | | ||
| const org = '${{ inputs.auto-review-org }}'; | ||
| const username = context.payload.pull_request.user.login; | ||
|
|
||
| try { | ||
| await github.rest.orgs.checkMembershipForUser({ | ||
| org: org, | ||
| username: username | ||
| }); | ||
| core.setOutput('is_member', 'true'); | ||
| console.log(`✅ ${username} is a ${org} org member - proceeding with auto-review`); | ||
| } catch (error) { | ||
| if (error.status === 404 || error.status === 302) { | ||
| core.setOutput('is_member', 'false'); | ||
| console.log(`⏭️ ${username} is not a ${org} org member - skipping auto-review`); | ||
| } else if (error.status === 401) { | ||
| core.setFailed( | ||
| '❌ ORG_MEMBERSHIP_TOKEN secret is missing or invalid.\n\n' + | ||
| `This secret is required to check ${org} org membership for auto-reviews.\n\n` + | ||
| 'To fix this:\n' + | ||
| '1. Create a classic PAT with read:org scope at https://github.com/settings/tokens/new\n' + | ||
| '2. Add it as an org secret named ORG_MEMBERSHIP_TOKEN' | ||
| ); | ||
| } else { | ||
| core.setFailed(`Failed to check org membership: ${error.message}`); | ||
| } | ||
| } | ||
|
|
||
| # Safe to checkout PR head because review-pr only READS files (no code execution) | ||
| - name: Checkout PR head | ||
| if: steps.membership.outputs.is_member == 'true' | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: refs/pull/${{ github.event.pull_request.number }}/head | ||
|
|
||
| # Generate GitHub App token for custom app identity (optional - falls back to github.token) | ||
| - name: Generate GitHub App token | ||
| if: steps.membership.outputs.is_member == 'true' && env.HAS_APP_SECRETS == 'true' | ||
| id: app-token | ||
| uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2 | ||
| with: | ||
| app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }} | ||
| private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Run PR Review | ||
| if: steps.membership.outputs.is_member == 'true' | ||
| id: run-review | ||
| uses: docker/cagent-action/review-pr@latest | ||
| with: | ||
| pr-number: ${{ inputs.pr-number || github.event.pull_request.number }} | ||
| additional-prompt: ${{ inputs.additional-prompt }} | ||
| model: ${{ inputs.model }} | ||
| cagent-version: ${{ inputs.cagent-version }} | ||
| github-token: ${{ steps.app-token.outputs.token || github.token }} | ||
| anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| openai-api-key: ${{ secrets.OPENAI_API_KEY }} | ||
| google-api-key: ${{ secrets.GOOGLE_API_KEY }} | ||
| aws-bearer-token-bedrock: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }} | ||
| xai-api-key: ${{ secrets.XAI_API_KEY }} | ||
| nebius-api-key: ${{ secrets.NEBIUS_API_KEY }} | ||
| mistral-api-key: ${{ secrets.MISTRAL_API_KEY }} | ||
|
|
||
| # ========================================================================== | ||
| # MANUAL REVIEW PIPELINE | ||
| # Triggers when someone comments /review on a PR | ||
| # ========================================================================== | ||
| manual-review: | ||
| if: github.event.issue.pull_request && contains(github.event.comment.body, '/review') | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }} | ||
| outputs: | ||
| exit-code: ${{ steps.run-review.outputs.exit-code }} | ||
|
|
||
| steps: | ||
| # Checkout PR head (not default branch) | ||
| # Note: Authorization is handled by the composite action's built-in check | ||
| - name: Checkout PR head | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: refs/pull/${{ github.event.issue.number }}/head | ||
|
|
||
| # Generate GitHub App token for custom app identity (optional - falls back to github.token) | ||
| - name: Generate GitHub App token | ||
| if: env.HAS_APP_SECRETS == 'true' | ||
| id: app-token | ||
| uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2 | ||
| with: | ||
| app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }} | ||
| private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Run PR Review | ||
| id: run-review | ||
| uses: docker/cagent-action/review-pr@latest | ||
| with: | ||
| pr-number: ${{ inputs.pr-number || github.event.issue.number }} | ||
| comment-id: ${{ inputs.comment-id || github.event.comment.id }} | ||
| additional-prompt: ${{ inputs.additional-prompt }} | ||
| model: ${{ inputs.model }} | ||
| cagent-version: ${{ inputs.cagent-version }} | ||
| github-token: ${{ steps.app-token.outputs.token || github.token }} | ||
| anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| openai-api-key: ${{ secrets.OPENAI_API_KEY }} | ||
| google-api-key: ${{ secrets.GOOGLE_API_KEY }} | ||
| aws-bearer-token-bedrock: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }} | ||
| xai-api-key: ${{ secrets.XAI_API_KEY }} | ||
| nebius-api-key: ${{ secrets.NEBIUS_API_KEY }} | ||
| mistral-api-key: ${{ secrets.MISTRAL_API_KEY }} | ||
|
|
||
| # ========================================================================== | ||
| # LEARN FROM FEEDBACK | ||
| # Processes replies to agent review comments for continuous improvement | ||
| # ========================================================================== | ||
| learn-from-feedback: | ||
| if: github.event_name == 'pull_request_review_comment' && github.event.comment.in_reply_to_id | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| # Generate GitHub App token for custom app identity (optional - falls back to github.token) | ||
| - name: Generate GitHub App token | ||
| if: env.HAS_APP_SECRETS == 'true' | ||
| id: app-token | ||
| uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2 | ||
| with: | ||
| app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }} | ||
| private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Learn from user feedback | ||
| uses: docker/cagent-action/review-pr/learn@latest | ||
| with: | ||
| github-token: ${{ steps.app-token.outputs.token || github.token }} | ||
| anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| openai-api-key: ${{ secrets.OPENAI_API_KEY }} | ||
| google-api-key: ${{ secrets.GOOGLE_API_KEY }} | ||
| aws-bearer-token-bedrock: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }} | ||
| xai-api-key: ${{ secrets.XAI_API_KEY }} | ||
| nebius-api-key: ${{ secrets.NEBIUS_API_KEY }} | ||
| mistral-api-key: ${{ secrets.MISTRAL_API_KEY }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost entirely copied and pasted from the review workflow in cagent.