workflows/.forgejo/workflows/ai-review.yml
Adam Williamson bbbe4cb4f3 ai-review: allow passing API key as AICR_API_KEY
Requiring it to be GEMINI_API_KEY was always a bit dumb, but now
we're allowing for the repo to contain a config file it's more
dumb, because a repo could include a config file that configures
a different model provider. Of course they can just have the key
for that provider under the name GEMINI_API_KEY and stuff will
work, but it looks dumb. So, let's allow (and prefer) the more
generic name AICR_API_KEY, which identifies this as "the key for
ai_code_review, whatever model provider it's configured for".

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2026-04-21 11:55:03 -07:00

40 lines
1.3 KiB
YAML

name: AI Code Review
on:
workflow_call:
inputs:
remove_label:
type: boolean
default: true
pr:
type: string
required: true
config:
type: string
required: false
description: A string to be written as an ai-code-review config file; use newline chars to separate lines
jobs:
ai-review:
container:
image: registry.gitlab.com/redhat/edge/ci-cd/ai-code-review:v2.5.0
steps:
- name: Write ai-code-review config file
run: |
mkdir -p .ai_review
printf "${{ inputs.config }}\n" > .ai_review/config.yml
if: ${{ inputs.config }}
- name: Run AI Review
env:
AI_API_KEY: ${{ secrets.AICR_API_KEY || secrets.GEMINI_API_KEY }}
run: ai-code-review --platform forgejo --pr-number ${{ inputs.pr }} --post
# this has to be a separate job because ai-code-review container does not have nodejs in it
# also note this does not work for PRs from forks because of a forgejo bug
# https://codeberg.org/forgejo/forgejo/issues/10733
remove-label:
if: ${{ inputs.remove_label }}
runs-on: fedora
steps:
- uses: https://github.com/actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0
with:
labels: ai-review-please