Skip to content
Draft
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
64 changes: 58 additions & 6 deletions .github/workflows/pr-describe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,67 @@ jobs:
# Only run if comment contains /describe and is on a PR
if: ${{ (github.event.issue.pull_request && contains(github.event.comment.body, '/describe')) }}
runs-on: ubuntu-latest
env:
HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }}
permissions:
contents: read
pull-requests: write
issues: write
checks: write
id-token: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: TODO_ROLE_ARN
aws-region: us-east-1

- name: Fetch GitHub App credentials from Secrets Manager
id: app-credentials
shell: bash
run: |
set -euo pipefail
SECRET=$(aws secretsmanager get-secret-value \
--secret-id docker-agent-action/github-app \
--query SecretString --output text)
APP_ID=$(echo "$SECRET" | jq -r .app_id)
ORG_TOKEN=$(echo "$SECRET" | jq -r .org_membership_token)
PRIVATE_KEY=$(echo "$SECRET" | jq -r .private_key)

if [ -z "$APP_ID" ] || [ "$APP_ID" = "null" ]; then
echo "::error::Failed to extract app_id from secret docker-agent-action/github-app"
exit 1
fi
if [ -z "$ORG_TOKEN" ] || [ "$ORG_TOKEN" = "null" ]; then
echo "::error::Failed to extract org_membership_token from secret docker-agent-action/github-app"
exit 1
fi
if [ -z "$PRIVATE_KEY" ] || [ "$PRIVATE_KEY" = "null" ]; then
echo "::error::Failed to extract private_key from secret docker-agent-action/github-app"
exit 1
fi

echo "::add-mask::$APP_ID"
echo "::add-mask::$ORG_TOKEN"
echo "::add-mask::$PRIVATE_KEY"
echo "app-id=$APP_ID" >> $GITHUB_OUTPUT
echo "org-membership-token=$ORG_TOKEN" >> $GITHUB_OUTPUT
DELIM="$(openssl rand -hex 8)"
{ echo "private-key<<$DELIM"; echo "$PRIVATE_KEY"; echo "$DELIM"; } >> $GITHUB_OUTPUT

- name: Fetch AI API keys from Secrets Manager
id: ai-api-keys
shell: bash
run: |
set -euo pipefail
SECRET=$(aws secretsmanager get-secret-value \
--secret-id docker-agent-action/ai-api-keys \
--query SecretString --output text)
ANTHROPIC_KEY=$(echo "$SECRET" | jq -r '.anthropic_api_key // ""')
OPENAI_KEY=$(echo "$SECRET" | jq -r '.openai_api_key // ""')
[ -n "$ANTHROPIC_KEY" ] && echo "::add-mask::$ANTHROPIC_KEY"
[ -n "$OPENAI_KEY" ] && echo "::add-mask::$OPENAI_KEY"
echo "anthropic-api-key=$ANTHROPIC_KEY" >> $GITHUB_OUTPUT
echo "openai-api-key=$OPENAI_KEY" >> $GITHUB_OUTPUT

- name: Check out Git repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

Expand Down Expand Up @@ -48,12 +101,11 @@ jobs:
# Generate GitHub App token so actions appear as the custom app (optional - falls back to github.token)
- name: Get GitHub App token
id: app-token
if: env.HAS_APP_SECRETS == 'true'
continue-on-error: true # Don't fail workflow if token generation fails
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
with:
app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }}
private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }}
app_id: ${{ steps.app-credentials.outputs.app-id }}
private_key: ${{ steps.app-credentials.outputs.private-key }}

- name: Validate PR and add reaction
id: validate_pr
Expand Down Expand Up @@ -180,7 +232,7 @@ jobs:

**Diff:**
$(cat pr.diff)
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY || steps.ai-api-keys.outputs.anthropic-api-key }}
github-token: ${{ steps.app-token.outputs.token || github.token }}
timeout: 300 # 5 minutes

Expand Down
75 changes: 67 additions & 8 deletions .github/workflows/reply-to-feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,75 @@ permissions:
pull-requests: write
issues: write
actions: read # Required to download artifacts from the triggering run
id-token: write

jobs:
reply:
# Only run if the triggering workflow succeeded (artifact was uploaded)
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }}
permissions:
contents: read
pull-requests: write
issues: write
actions: read
id-token: write

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: TODO_ROLE_ARN
aws-region: us-east-1

- name: Fetch GitHub App credentials from Secrets Manager
id: app-credentials
shell: bash
run: |
set -euo pipefail
SECRET=$(aws secretsmanager get-secret-value \
--secret-id docker-agent-action/github-app \
--query SecretString --output text)
APP_ID=$(echo "$SECRET" | jq -r .app_id)
ORG_TOKEN=$(echo "$SECRET" | jq -r .org_membership_token)
PRIVATE_KEY=$(echo "$SECRET" | jq -r .private_key)

if [ -z "$APP_ID" ] || [ "$APP_ID" = "null" ]; then
echo "::error::Failed to extract app_id from secret docker-agent-action/github-app"
exit 1
fi
if [ -z "$ORG_TOKEN" ] || [ "$ORG_TOKEN" = "null" ]; then
echo "::error::Failed to extract org_membership_token from secret docker-agent-action/github-app"
exit 1
fi
if [ -z "$PRIVATE_KEY" ] || [ "$PRIVATE_KEY" = "null" ]; then
echo "::error::Failed to extract private_key from secret docker-agent-action/github-app"
exit 1
fi

echo "::add-mask::$APP_ID"
echo "::add-mask::$ORG_TOKEN"
echo "::add-mask::$PRIVATE_KEY"
echo "app-id=$APP_ID" >> $GITHUB_OUTPUT
echo "org-membership-token=$ORG_TOKEN" >> $GITHUB_OUTPUT
DELIM="$(openssl rand -hex 8)"
{ echo "private-key<<$DELIM"; echo "$PRIVATE_KEY"; echo "$DELIM"; } >> $GITHUB_OUTPUT

- name: Fetch AI API keys from Secrets Manager
id: ai-api-keys
shell: bash
run: |
set -euo pipefail
SECRET=$(aws secretsmanager get-secret-value \
--secret-id docker-agent-action/ai-api-keys \
--query SecretString --output text)
ANTHROPIC_KEY=$(echo "$SECRET" | jq -r '.anthropic_api_key // ""')
OPENAI_KEY=$(echo "$SECRET" | jq -r '.openai_api_key // ""')
[ -n "$ANTHROPIC_KEY" ] && echo "::add-mask::$ANTHROPIC_KEY"
[ -n "$OPENAI_KEY" ] && echo "::add-mask::$OPENAI_KEY"
echo "anthropic-api-key=$ANTHROPIC_KEY" >> $GITHUB_OUTPUT
echo "openai-api-key=$OPENAI_KEY" >> $GITHUB_OUTPUT

# ----------------------------------------------------------------
# Download artifact from the triggering workflow run
# ----------------------------------------------------------------
Expand Down Expand Up @@ -157,7 +216,7 @@ jobs:
env:
USERNAME: ${{ steps.meta.outputs.author }}
with:
github-token: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }}
github-token: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN || steps.app-credentials.outputs.org-membership-token }}
script: |
const org = 'docker';
const username = process.env.USERNAME;
Expand Down Expand Up @@ -301,13 +360,13 @@ jobs:
ref: refs/pull/${{ steps.meta.outputs.pr_number }}/head

- name: Generate GitHub App token
if: steps.meta.outputs.proceed == 'true' && steps.auth.outputs.authorized == 'true' && env.HAS_APP_SECRETS == 'true'
if: steps.meta.outputs.proceed == 'true' && steps.auth.outputs.authorized == 'true'
id: app-token
continue-on-error: true
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
with:
app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }}
private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }}
app_id: ${{ steps.app-credentials.outputs.app-id }}
private_key: ${{ steps.app-credentials.outputs.private-key }}

- name: Run reply
if: steps.meta.outputs.proceed == 'true' && steps.auth.outputs.authorized == 'true' && steps.checkout.outcome == 'success' && steps.thread.outcome == 'success'
Expand All @@ -317,8 +376,8 @@ jobs:
with:
thread-context: ${{ steps.thread.outputs.prompt }}
comment-id: ${{ steps.meta.outputs.comment_id }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY || steps.ai-api-keys.outputs.anthropic-api-key }}
openai-api-key: ${{ secrets.OPENAI_API_KEY || steps.ai-api-keys.outputs.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 }}
Expand Down
Loading
Loading