-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
97 lines (90 loc) · 3.33 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: 'Patched AutoFix'
description: 'Run Autofix patchflow using patchwork-cli to automatically fix code vulnerabilities'
branding:
icon: 'shield'
color: 'green'
author: '@patched-codes'
inputs:
github_token:
description: 'GitHub token for creating pull requests'
required: false
default: ${{ github.token }}
openai_api_key:
description: 'OpenAI API key for the LLM'
required: false
patched_api_key:
description: 'Patched API key for using Patched services'
required: false
model:
description: 'LLM model to use'
required: false
client_base_url:
description: 'Base URL for the LLM API'
required: false
vulnerability_limit:
description: 'Maximum number of vulnerabilities to fix'
required: false
severity:
description: 'Minimum severity level of vulnerabilities to fix'
required: false
compatibility:
description: 'Minimum compatibility threshold for fixes'
required: false
branch_prefix:
description: 'Prefix for the created branch'
required: false
default: 'patched-autofix/'
disable_branch:
description: 'Disable creating new branches'
required: false
disable_pr:
description: 'Disable creating pull requests'
required: false
force_pr_creation:
description: 'Force push commits to existing PR'
required: false
outputs:
pr_url:
description: 'URL of the created pull request'
value: ${{ steps.autofix.outputs.pr_url }}
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Restore pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-patchwork-cli[security]
restore-keys: |
${{ runner.os }}-pip-patchwork-cli[security]
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install 'patchwork-cli[security]'
- name: Generate config
shell: bash
run: |
cat > config.yml << EOF
github_api_key: "${{ inputs.github_token }}"
$([ -n "${{ inputs.openai_api_key }}" ] && echo "openai_api_key: \"${{ inputs.openai_api_key }}\"")
$([ -n "${{ inputs.patched_api_key }}" ] && echo "patched_api_key: \"${{ inputs.patched_api_key }}\"")
$([ -n "${{ inputs.model }}" ] && echo "model: \"${{ inputs.model }}\"")
$([ -n "${{ inputs.client_base_url }}" ] && echo "client_base_url: \"${{ inputs.client_base_url }}\"")
$([ -n "${{ inputs.vulnerability_limit }}" ] && echo "vulnerability_limit: ${{ inputs.vulnerability_limit }}")
$([ -n "${{ inputs.severity }}" ] && echo "severity: \"${{ inputs.severity }}\"")
$([ -n "${{ inputs.compatibility }}" ] && echo "compatibility: \"${{ inputs.compatibility }}\"")
$([ -n "${{ inputs.branch_prefix }}" ] && echo "branch_prefix: \"${{ inputs.branch_prefix }}\"")
$([ -n "${{ inputs.disable_branch }}" ] && echo "disable_branch: ${{ inputs.disable_branch }}")
$([ -n "${{ inputs.disable_pr }}" ] && echo "disable_pr: ${{ inputs.disable_pr }}")
$([ -n "${{ inputs.force_pr_creation }}" ] && echo "force_pr_creation: ${{ inputs.force_pr_creation }}")
EOF
- name: Run Autofix
id: autofix
shell: bash
run: |
patchwork AutoFix --config config.yml