anc95 / ChatGPT-CodeReview

🐥 A code review bot powered by ChatGPT
https://github.com/apps/cr-gpt
ISC License
3.78k stars 361 forks source link

Run only on labeled PRs #43

Closed JohannesArtmeier closed 1 year ago

JohannesArtmeier commented 1 year ago

Hey,

I love it! Awesome job. I'm trying to run it only when I set a particular label for the PR (to save tokens for small PRs).

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, reopened, labeled]

jobs:
  test:
    if: github.event.label.name == 'GPT-CR'
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/ChatGPT-CodeReview@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          # Optional
          LANGUAGE: English

I also get the action triggered, but for some reason, no feedback is posted on the PR. Here is the action result: image

Any idea why no feedback is provided?

anc95 commented 1 year ago

HI, @JohannesArtmeier , the result is expected, only the opened / synchronize event are handled in the review action.

JohannesArtmeier commented 1 year ago

Any idea how to get it worked to run not on all PRs?

neo-cheung commented 1 year ago

GitHub action does not support filter by label yet https://github.com/community/community/discussions/14407 but you can use the if command to filter job by label https://github.com/orgs/community/discussions/26261

anc95 commented 1 year ago

@JohannesArtmeier I think in bellow case you set label it should work as your expection.

you can set the label when creating new pull request, as bellow, because the action triggered by open, and we have contains(github.event.pull_request.labels.*.name, 'cr.gpt') to decide if execute the CR action.

image