|
| 1 | +name: 'Patched GenerateDocstring' |
| 2 | +description: 'Automatically document methods in your code by generating docstrings' |
| 3 | +branding: |
| 4 | + icon: 'file-text' |
| 5 | + color: 'purple' |
| 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 | + base_path: |
| 17 | + description: 'Base path to start generating docstrings from' |
| 18 | + required: false |
| 19 | + default: '.' |
| 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 | + rewrite_existing: |
| 27 | + description: 'Whether to rewrite existing docstrings' |
| 28 | + required: false |
| 29 | + branch_prefix: |
| 30 | + description: 'Prefix for the created branch' |
| 31 | + required: false |
| 32 | + default: 'patched-generate-docstring/' |
| 33 | + disable_branch: |
| 34 | + description: 'Disable creating new branches' |
| 35 | + required: false |
| 36 | + disable_pr: |
| 37 | + description: 'Disable creating pull requests' |
| 38 | + required: false |
| 39 | + force_pr_creation: |
| 40 | + description: 'Force push commits to existing PR' |
| 41 | + required: false |
| 42 | + model_temperature: |
| 43 | + description: 'Temperature parameter for the LLM' |
| 44 | + required: false |
| 45 | + model_top_p: |
| 46 | + description: 'Top-p parameter for the LLM' |
| 47 | + required: false |
| 48 | + model_max_tokens: |
| 49 | + description: 'Maximum tokens for the LLM response' |
| 50 | + required: false |
| 51 | + |
| 52 | +outputs: |
| 53 | + pr_url: |
| 54 | + description: 'URL of the created pull request' |
| 55 | + value: ${{ steps.generate-docstring.outputs.pr_url }} |
| 56 | + |
| 57 | +runs: |
| 58 | + using: 'composite' |
| 59 | + steps: |
| 60 | + - name: Set up Python |
| 61 | + uses: actions/setup-python@v4 |
| 62 | + with: |
| 63 | + python-version: '3.x' |
| 64 | + |
| 65 | + - name: Restore pip cache |
| 66 | + uses: actions/cache@v3 |
| 67 | + with: |
| 68 | + path: ~/.cache/pip |
| 69 | + key: ${{ runner.os }}-pip-patchwork-cli |
| 70 | + restore-keys: | |
| 71 | + ${{ runner.os }}-pip-patchwork-cli |
| 72 | +
|
| 73 | + - name: Install dependencies |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + python -m pip install --upgrade pip |
| 77 | + pip install patchwork-cli |
| 78 | +
|
| 79 | + - name: Generate config |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + cat > config.yml << EOF |
| 83 | + github_api_key: "${{ inputs.github_token }}" |
| 84 | + $([ -n "${{ inputs.openai_api_key }}" ] && echo "openai_api_key: \"${{ inputs.openai_api_key }}\"") |
| 85 | + $([ -n "${{ inputs.base_path }}" ] && echo "base_path: \"${{ inputs.base_path }}\"") |
| 86 | + $([ -n "${{ inputs.model }}" ] && echo "model: \"${{ inputs.model }}\"") |
| 87 | + $([ -n "${{ inputs.client_base_url }}" ] && echo "client_base_url: \"${{ inputs.client_base_url }}\"") |
| 88 | + $([ -n "${{ inputs.rewrite_existing }}" ] && echo "rewrite_existing: ${{ inputs.rewrite_existing }}") |
| 89 | + $([ -n "${{ inputs.branch_prefix }}" ] && echo "branch_prefix: \"${{ inputs.branch_prefix }}\"") |
| 90 | + $([ -n "${{ inputs.disable_branch }}" ] && echo "disable_branch: ${{ inputs.disable_branch }}") |
| 91 | + $([ -n "${{ inputs.disable_pr }}" ] && echo "disable_pr: ${{ inputs.disable_pr }}") |
| 92 | + $([ -n "${{ inputs.force_pr_creation }}" ] && echo "force_pr_creation: ${{ inputs.force_pr_creation }}") |
| 93 | + $([ -n "${{ inputs.model_temperature }}" ] && echo "model_temperature: ${{ inputs.model_temperature }}") |
| 94 | + $([ -n "${{ inputs.model_top_p }}" ] && echo "model_top_p: ${{ inputs.model_top_p }}") |
| 95 | + $([ -n "${{ inputs.model_max_tokens }}" ] && echo "model_max_tokens: ${{ inputs.model_max_tokens }}") |
| 96 | + EOF |
| 97 | +
|
| 98 | + - name: Run GenerateDocstring |
| 99 | + id: generate-docstring |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + patchwork GenerateDocstring --config config.yml |
0 commit comments