Skip to content

Commit ae1c6d4

Browse files
Add CodeBoarding architecture analysis: add codeboarding.yml
1 parent ae5f0ec commit ae1c6d4

1 file changed

Lines changed: 9 additions & 80 deletions

File tree

.github/workflows/codeboarding.yml

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,31 @@ name: CodeBoarding review
22

33
on:
44
pull_request:
5-
# Generate once, when the PR becomes reviewable, not on every push, so we
6-
# don't spend an LLM job per commit. Add `synchronize` to re-run on each
7-
# push, or refresh anytime with /codeboarding. 'closed' only cancels an
8-
# in-flight review (see concurrency), it doesn't start one.
95
types: [opened, reopened, ready_for_review, closed]
106
issue_comment:
117
types: [created]
128

13-
permissions:
14-
# write: the action commits the generated .codeboarding/analysis.json back to the
15-
# PR branch so the webview can open this PR's diff at the head SHA (same-repo PRs).
16-
contents: write
17-
pull-requests: write
18-
issues: write
9+
# No workflow-level permissions: each job requests only what it needs (least
10+
# privilege), so the default token starts with none.
11+
permissions: {}
1912

2013
concurrency:
2114
group: codeboarding-${{ github.event.pull_request.number || github.event.issue.number }}
22-
# Cancel only when the PR closes — bot comments (issue_comment) and re-triggers
23-
# must not cancel a running review; they queue behind it instead.
2415
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
2516

2617
jobs:
2718
review:
2819
runs-on: ubuntu-latest
2920
timeout-minutes: 60
21+
permissions:
22+
contents: read # check out the repo + read the committed baseline (no writes in review mode)
23+
pull-requests: write # post the architecture-diff PR comment
24+
issues: write # the /codeboarding issue_comment trigger + comment API
25+
id-token: write # mint a GitHub OIDC token for the free hosted tier (write is the only level for id-token)
3026
if: >
3127
(github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.draft == false) ||
3228
(github.event_name == 'issue_comment' && github.event.issue.pull_request != null &&
3329
startsWith(github.event.comment.body, '/codeboarding') &&
3430
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association))
3531
steps:
36-
# Dogfood: run the action from the checked-out repo (uses: ./) so each PR
37-
# exercises the action code under review, not the last published release.
38-
# The action reads its scripts via github.action_path and checks the engine
39-
# and target repo into subdirectories, so this local checkout is untouched.
40-
- uses: actions/checkout@v4
41-
- name: Detect CodeBoarding GitHub App credentials
42-
id: codeboarding-app-config
43-
shell: bash
44-
env:
45-
CLIENT_ID: ${{ vars.CODEBOARDING_APP_CLIENT_ID }}
46-
APP_ID: ${{ vars.CODEBOARDING_APP_ID }}
47-
PRIVATE_KEY: ${{ secrets.CODEBOARDING_APP_PRIVATE_KEY }}
48-
run: |
49-
client_id="${CLIENT_ID:-}"
50-
app_id="${APP_ID:-}"
51-
52-
# GitHub App client IDs start with "Iv". If that value was stored in
53-
# CODEBOARDING_APP_ID, use it as a client ID to avoid the deprecated
54-
# app-id input path.
55-
if [ -z "$client_id" ] && [ "${app_id#Iv}" != "$app_id" ]; then
56-
client_id="$app_id"
57-
app_id=""
58-
fi
59-
60-
has_private_key=false
61-
private_key_valid=false
62-
if [ -n "$PRIVATE_KEY" ]; then
63-
has_private_key=true
64-
if printf '%s' "$PRIVATE_KEY" | openssl pkey -noout >/dev/null 2>&1; then
65-
private_key_valid=true
66-
else
67-
echo "::warning::CODEBOARDING_APP_PRIVATE_KEY is not a valid PEM private key, so CodeBoarding will fall back to github-actions[bot]."
68-
if printf '%b' "$PRIVATE_KEY" | openssl pkey -noout >/dev/null 2>&1; then
69-
printf '%s\n' "::warning::CODEBOARDING_APP_PRIVATE_KEY looks like it contains literal \\n escapes. Store the downloaded PEM as multi-line secret text instead."
70-
fi
71-
fi
72-
fi
73-
74-
{
75-
[ -n "$client_id" ] && echo "has_client_id=true" || echo "has_client_id=false"
76-
[ -n "$app_id" ] && echo "has_app_id=true" || echo "has_app_id=false"
77-
echo "client_id=$client_id"
78-
echo "has_private_key=$has_private_key"
79-
echo "private_key_valid=$private_key_valid"
80-
} >> "$GITHUB_OUTPUT"
81-
- uses: actions/create-github-app-token@v3
82-
id: codeboarding-app-token-client
83-
if: steps.codeboarding-app-config.outputs.has_client_id == 'true' && steps.codeboarding-app-config.outputs.private_key_valid == 'true'
84-
continue-on-error: true
85-
with:
86-
client-id: ${{ steps.codeboarding-app-config.outputs.client_id }}
87-
private-key: ${{ secrets.CODEBOARDING_APP_PRIVATE_KEY }}
88-
- uses: actions/create-github-app-token@v3
89-
id: codeboarding-app-token-app
90-
if: steps.codeboarding-app-config.outputs.has_client_id != 'true' && steps.codeboarding-app-config.outputs.has_app_id == 'true' && steps.codeboarding-app-config.outputs.private_key_valid == 'true'
91-
continue-on-error: true
92-
with:
93-
app-id: ${{ vars.CODEBOARDING_APP_ID }}
94-
private-key: ${{ secrets.CODEBOARDING_APP_PRIVATE_KEY }}
95-
- name: Warn when CodeBoarding App token is unavailable
96-
if: steps.codeboarding-app-token-client.outputs.token == '' && steps.codeboarding-app-token-app.outputs.token == ''
97-
shell: bash
98-
run: |
99-
echo "::warning::CodeBoarding GitHub App token is unavailable; falling back to github-actions[bot]. Check CODEBOARDING_APP_PRIVATE_KEY formatting if app credentials are configured."
100-
- uses: ./
101-
with:
102-
github_token: ${{ steps.codeboarding-app-token-client.outputs.token || steps.codeboarding-app-token-app.outputs.token || github.token }}
103-
llm_api_key: ${{ secrets.OPENROUTER_API_KEY }}
32+
- uses: CodeBoarding/CodeBoarding-action@v1

0 commit comments

Comments
 (0)