Skip to content

Commit 2d37dfe

Browse files
committed
Update the config passing
1 parent f6533c5 commit 2d37dfe

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

action.yml

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,33 @@ inputs:
1717
description: 'Patched API key for using Patched services'
1818
required: false
1919
model:
20-
description: 'LLM model to use (default: gpt-3.5-turbo)'
20+
description: 'LLM model to use'
2121
required: false
22-
default: 'gpt-3.5-turbo'
2322
client_base_url:
24-
description: 'Base URL for the LLM API (default: https://api.openai.com/v1)'
23+
description: 'Base URL for the LLM API'
2524
required: false
26-
default: 'https://api.openai.com/v1'
2725
vulnerability_limit:
28-
description: 'Maximum number of vulnerabilities to fix (default: 10, -1 for no limit)'
26+
description: 'Maximum number of vulnerabilities to fix'
2927
required: false
30-
default: '10'
3128
severity:
32-
description: 'Minimum severity level of vulnerabilities to fix (unknown/note/info/warning/low/medium/error/high/critical)'
29+
description: 'Minimum severity level of vulnerabilities to fix'
3330
required: false
34-
default: 'medium'
3531
compatibility:
36-
description: 'Minimum compatibility threshold for fixes (unknown/low/medium/high)'
32+
description: 'Minimum compatibility threshold for fixes'
3733
required: false
38-
default: 'medium'
3934
branch_prefix:
4035
description: 'Prefix for the created branch'
4136
required: false
42-
default: 'autofix'
37+
default: 'patchwork-autofix/'
4338
disable_branch:
4439
description: 'Disable creating new branches'
4540
required: false
46-
default: 'false'
4741
disable_pr:
4842
description: 'Disable creating pull requests'
4943
required: false
50-
default: 'false'
5144
force_pr_creation:
5245
description: 'Force push commits to existing PR'
5346
required: false
54-
default: 'false'
5547

5648
outputs:
5749
pr_url:
@@ -66,7 +58,7 @@ runs:
6658
with:
6759
python-version: '3.x'
6860

69-
- name: Set up pip cache
61+
- name: Restore pip cache
7062
uses: actions/cache@v3
7163
with:
7264
path: ~/.cache/pip
@@ -80,27 +72,26 @@ runs:
8072
python -m pip install --upgrade pip
8173
pip install 'patchwork-cli[security]'
8274
75+
- name: Generate config
76+
shell: bash
77+
run: |
78+
cat > config.yml << EOF
79+
github_api_key: "${{ inputs.github_token }}"
80+
$([ -n "${{ inputs.openai_api_key }}" ] && echo "openai_api_key: \"${{ inputs.openai_api_key }}\"")
81+
$([ -n "${{ inputs.patched_api_key }}" ] && echo "patched_api_key: \"${{ inputs.patched_api_key }}\"")
82+
$([ -n "${{ inputs.model }}" ] && echo "model: \"${{ inputs.model }}\"")
83+
$([ -n "${{ inputs.client_base_url }}" ] && echo "client_base_url: \"${{ inputs.client_base_url }}\"")
84+
$([ -n "${{ inputs.vulnerability_limit }}" ] && echo "vulnerability_limit: ${{ inputs.vulnerability_limit }}")
85+
$([ -n "${{ inputs.severity }}" ] && echo "severity: \"${{ inputs.severity }}\"")
86+
$([ -n "${{ inputs.compatibility }}" ] && echo "compatibility: \"${{ inputs.compatibility }}\"")
87+
$([ -n "${{ inputs.branch_prefix }}" ] && echo "branch_prefix: \"${{ inputs.branch_prefix }}\"")
88+
$([ -n "${{ inputs.disable_branch }}" ] && echo "disable_branch: ${{ inputs.disable_branch }}")
89+
$([ -n "${{ inputs.disable_pr }}" ] && echo "disable_pr: ${{ inputs.disable_pr }}")
90+
$([ -n "${{ inputs.force_pr_creation }}" ] && echo "force_pr_creation: ${{ inputs.force_pr_creation }}")
91+
EOF
92+
8393
- name: Run Autofix
8494
id: autofix
8595
shell: bash
8696
run: |
87-
args=()
88-
args+=("github_api_key=${{ inputs.github_token }}")
89-
if [ -n "${{ inputs.openai_api_key }}" ]; then
90-
args+=("openai_api_key=${{ inputs.openai_api_key }}")
91-
fi
92-
if [ -n "${{ inputs.patched_api_key }}" ]; then
93-
args+=("patched_api_key=${{ inputs.patched_api_key }}")
94-
fi
95-
args+=(
96-
"model=${{ inputs.model }}"
97-
"client_base_url=${{ inputs.client_base_url }}"
98-
"vulnerability_limit=${{ inputs.vulnerability_limit }}"
99-
"severity=${{ inputs.severity }}"
100-
"compatibility=${{ inputs.compatibility }}"
101-
"branch_prefix=${{ inputs.branch_prefix }}"
102-
"disable_branch=${{ inputs.disable_branch }}"
103-
"disable_pr=${{ inputs.disable_pr }}"
104-
"force_pr_creation=${{ inputs.force_pr_creation }}"
105-
)
106-
patchwork AutoFix "${args[@]}"
97+
patchwork AutoFix --config config.yml

0 commit comments

Comments
 (0)