From bef80c01e36cc81bd25dbfadf2ff9084d21ed695 Mon Sep 17 00:00:00 2001 From: Fly Over Coder Date: Sun, 16 Aug 2026 18:19:32 +0000 Subject: [PATCH 1/2] Allow Grok reviews to use XAI_API_KEY Write ~/.grok/config.toml only when the API key secret is set, keep GROK_AUTH_JSON as fallback, and pin the review action to v1.0.2. Co-authored-by: Fly Over Coder --- .github/workflows/grok-code-review.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/grok-code-review.yml b/.github/workflows/grok-code-review.yml index 72700b9..ce11c48 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: ${{ secrets.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" From 6a2da54a7f60a807550140235f1093b2e19eaae4 Mon Sep 17 00:00:00 2001 From: Fly Over Coder Date: Sun, 16 Aug 2026 19:14:40 +0000 Subject: [PATCH 2/2] Fix Grok review step if to use env context GitHub rejects secrets in step-level if expressions, which blocked workflow validation. Gate the config write on env.XAI_API_KEY instead. Co-authored-by: Fly Over Coder --- .github/workflows/grok-code-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grok-code-review.yml b/.github/workflows/grok-code-review.yml index ce11c48..ee496b8 100644 --- a/.github/workflows/grok-code-review.yml +++ b/.github/workflows/grok-code-review.yml @@ -41,7 +41,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha || github.sha }} - name: Write Grok API key config - if: ${{ secrets.XAI_API_KEY != '' }} + if: ${{ env.XAI_API_KEY != '' }} run: | mkdir -p "$HOME/.grok" cat > "$HOME/.grok/config.toml" <<'EOF'