diff --git a/.github/workflows/grok-code-review.yml b/.github/workflows/grok-code-review.yml index 72700b9..ee496b8 100644 --- a/.github/workflows/grok-code-review.yml +++ b/.github/workflows/grok-code-review.yml @@ -1,6 +1,7 @@ # Organization-required Grok Build PR review. # Enforced via org ruleset "Require Grok code review" pointing at this file. -# Secret: org-level GROK_AUTH_JSON (contents of ~/.grok/auth.json after `grok login`). +# Secrets: org-level XAI_API_KEY (preferred; CLI env_key) and GROK_AUTH_JSON +# (fallback; contents of ~/.grok/auth.json after `grok login`). name: Grok code review on: @@ -30,6 +31,8 @@ jobs: (github.event_name == 'pull_request' && !github.event.pull_request.draft) runs-on: ubuntu-latest timeout-minutes: 30 + env: + XAI_API_KEY: ${{ secrets.XAI_API_KEY }} steps: - name: Checkout PR head uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -37,9 +40,20 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha || github.sha }} + - name: Write Grok API key config + if: ${{ env.XAI_API_KEY != '' }} + run: | + mkdir -p "$HOME/.grok" + cat > "$HOME/.grok/config.toml" <<'EOF' + [model.grok-build] + env_key = "XAI_API_KEY" + [models] + default = "grok-build" + EOF + - name: Run Grok Build review id: grok - uses: 0xr3ngar/grok-build-review-action@331c5b469a19e33d1eda69a0c06efc7d128b625a # v1.0.1 + uses: 0xr3ngar/grok-build-review-action@eded30018cdee4e83dfca14d18f292b860c30cdd # v1.0.2 with: grok_auth_json: ${{ secrets.GROK_AUTH_JSON }} github_token: ${{ github.token }} @@ -60,4 +74,4 @@ jobs: echo "| Issues | \`${{ steps.grok.outputs.issue_count }}\` |" echo "| Bugs | \`${{ steps.grok.outputs.bug_count }}\` |" echo "| Review | ${{ steps.grok.outputs.review_url }}" - } >> "$GITHUB_STEP_SUMMARY" \ No newline at end of file + } >> "$GITHUB_STEP_SUMMARY"