|
| 1 | +name: 'Patched PRReview' |
| 2 | +description: 'Automatically summarize and comment on PRs in your repository' |
| 3 | +branding: |
| 4 | + icon: 'git-pull-request' |
| 5 | + color: 'orange' |
| 6 | +author: '@patched-codes' |
| 7 | + |
| 8 | +inputs: |
| 9 | + github_token: |
| 10 | + description: 'GitHub token for creating pull requests' |
| 11 | + required: false |
| 12 | + default: ${{ github.token }} |
| 13 | + openai_api_key: |
| 14 | + description: 'OpenAI API key for the LLM' |
| 15 | + required: false |
| 16 | + pr_url: |
| 17 | + description: 'URL of the pull request to review' |
| 18 | + required: true |
| 19 | + default: ${{ github.event.pull_request.html_url }} |
| 20 | + model: |
| 21 | + description: 'LLM model to use' |
| 22 | + required: false |
| 23 | + client_base_url: |
| 24 | + description: 'Base URL for the LLM API' |
| 25 | + required: false |
| 26 | + diff_suggestion: |
| 27 | + description: 'Whether to generate suggestions to improve the PR' |
| 28 | + required: false |
| 29 | + diff_summary: |
| 30 | + description: 'Length of the summary (long, short, none)' |
| 31 | + required: false |
| 32 | + model_temperature: |
| 33 | + description: 'Temperature parameter for the LLM' |
| 34 | + required: false |
| 35 | + model_top_p: |
| 36 | + description: 'Top-p parameter for the LLM' |
| 37 | + required: false |
| 38 | + model_max_tokens: |
| 39 | + description: 'Maximum tokens for the LLM response' |
| 40 | + required: false |
| 41 | + |
| 42 | +outputs: |
| 43 | + comment_url: |
| 44 | + description: 'URL of the created PR comment' |
| 45 | + value: ${{ steps.pr-review.outputs.comment_url }} |
| 46 | + |
| 47 | +runs: |
| 48 | + using: 'composite' |
| 49 | + steps: |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v4 |
| 52 | + with: |
| 53 | + python-version: '3.x' |
| 54 | + |
| 55 | + - name: Restore pip cache |
| 56 | + uses: actions/cache@v3 |
| 57 | + with: |
| 58 | + path: ~/.cache/pip |
| 59 | + key: ${{ runner.os }}-pip-patchwork-cli |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-pip-patchwork-cli |
| 62 | +
|
| 63 | + - name: Install dependencies |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + python -m pip install --upgrade pip |
| 67 | + pip install patchwork-cli |
| 68 | +
|
| 69 | + - name: Generate config |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + cat > config.yml << EOF |
| 73 | + github_api_key: "${{ inputs.github_token }}" |
| 74 | + $([ -n "${{ inputs.openai_api_key }}" ] && echo "openai_api_key: \"${{ inputs.openai_api_key }}\"") |
| 75 | + $([ -n "${{ inputs.pr_url }}" ] && echo "pr_url: \"${{ inputs.pr_url }}\"") |
| 76 | + $([ -n "${{ inputs.model }}" ] && echo "model: \"${{ inputs.model }}\"") |
| 77 | + $([ -n "${{ inputs.client_base_url }}" ] && echo "client_base_url: \"${{ inputs.client_base_url }}\"") |
| 78 | + $([ -n "${{ inputs.diff_suggestion }}" ] && echo "diff_suggestion: ${{ inputs.diff_suggestion }}") |
| 79 | + $([ -n "${{ inputs.diff_summary }}" ] && echo "diff_summary: \"${{ inputs.diff_summary }}\"") |
| 80 | + $([ -n "${{ inputs.model_temperature }}" ] && echo "model_temperature: ${{ inputs.model_temperature }}") |
| 81 | + $([ -n "${{ inputs.model_top_p }}" ] && echo "model_top_p: ${{ inputs.model_top_p }}") |
| 82 | + $([ -n "${{ inputs.model_max_tokens }}" ] && echo "model_max_tokens: ${{ inputs.model_max_tokens }}") |
| 83 | + EOF |
| 84 | +
|
| 85 | + - name: Run PRReview |
| 86 | + id: pr-review |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + patchwork PRReview --config config.yml |
0 commit comments