Add Claude Code GitHub Workflow #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF licenses this file to You under the Apache License, Version 2.0 | |
| # (the "License"); you may not use this file except in compliance with | |
| # the License. You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # For most projects, this workflow file will not need changing; you simply need | |
| # to commit it to your repository. | |
| # You may wish to alter this file to override the set of languages analyzed, | |
| # or to provide custom queries or build logic. | |
| name: Codex PR review | |
| on: | |
| pull_request: | |
| types: [opened] | |
| jobs: | |
| codex: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| final_message: ${{ steps.run_codex.outputs.final-message }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # Explicitly check out the PR's merge commit. | |
| ref: refs/pull/${{ github.event.pull_request.number }}/merge | |
| - name: Pre-fetch base and head refs for the PR | |
| run: | | |
| git fetch --no-tags origin \ | |
| ${{ github.event.pull_request.base.ref }} \ | |
| +refs/pull/${{ github.event.pull_request.number }}/head | |
| # If you want Codex to build and run code, install any dependencies that | |
| # need to be downloaded before the "Run Codex" step because Codex's | |
| # default sandbox disables network access. | |
| - name: Run Codex | |
| id: run_codex | |
| uses: openai/codex-action@v1 | |
| with: | |
| openai-api-key: ${{ secrets.OPENAI_API_KEY }} | |
| prompt: | | |
| This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}. | |
| Base SHA: ${{ github.event.pull_request.base.sha }} | |
| Head SHA: ${{ github.event.pull_request.head.sha }} | |
| Review ONLY the changes introduced by the PR. | |
| Suggest any improvements, potential bugs, or issues. | |
| Be concise and specific in your feedback. | |
| Pull request title and body: | |
| ---- | |
| ${{ github.event.pull_request.title }} | |
| ${{ github.event.pull_request.body }} | |
| post_feedback: | |
| runs-on: ubuntu-latest | |
| needs: codex | |
| if: needs.codex.outputs.final_message != '' | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Report Codex feedback | |
| uses: actions/github-script@v7 | |
| env: | |
| CODEX_FINAL_MESSAGE: ${{ needs.codex.outputs.final_message }} | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body: process.env.CODEX_FINAL_MESSAGE, | |
| }); |