Add support for workflows #4
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
| name: Perform a code review when a pull request is created. | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review, labeled] | |
| jobs: | |
| codex: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| outputs: | |
| final_message: ${{ steps.run_codex.outputs.final-message }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| 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 | |
| - 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, security issues, 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, | |
| }); |