Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
.github/instructions
.github/instructions
.codacy/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ steps:
| `tool` | Yes | - | The tool to use for analysis. |
| `upload_report` | No | false | Whether to upload the report to Codacy. |
| `sarif_file_path` | No | "./report.sarif" | The path to the SARIF file to upload. |
| `tool_config_path` | No | - | The path to the tool configuration file you need for the analysis. |
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ inputs:
default: ""
description: >-
Eventual registry address.
tool_config_path:
required: false
default: ""
description: >-
Path to the tool configuration file to use for the analysis. If not provided, the action will rely on the default configuration provided by Codacy CLI V2.

runs:
using: "composite"
Expand All @@ -64,6 +69,9 @@ runs:
if [ "${{ inputs.api_token }}" != "" ]; then
/tmp/codacy-cli-v2 init --api-token ${{inputs.api_token}} --provider ${{inputs.provider}} --organization ${{inputs.owner}} --repository ${{inputs.repository}}
fi
if [ "${{ inputs.tool_config_path }}" != "" ]; then
mv "${{ inputs.tool_config_path }}" ./.codacy/tools-configs/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The move operation assumes the destination directory ./.codacy/tools-configs/ already exists. In most fresh checkouts, this directory will be missing, causing the mv command to fail and the entire action to crash.

This might be a simple fix:

Suggested change
mv "${{ inputs.tool_config_path }}" ./.codacy/tools-configs/
mkdir -p ./.codacy/tools-configs/ && mv "${{ inputs.tool_config_path }}" ./.codacy/tools-configs/

fi
if [ "${{ inputs.registry }}" != "" ]; then
/tmp/codacy-cli-v2 install -r ${{ inputs.registry }}
else
Expand All @@ -75,7 +83,7 @@ runs:
run: |
echo "Running the tool"
if [ "${{ inputs.api_token }}" != "" ]; then
/tmp/codacy-cli-v2 analyze -t ${{inputs.tool}} ${{inputs.directory}} --format sarif -o ${{inputs.sarif_file_path}} --api-token ${{inputs.api_token}} --provider ${{inputs.provider}} --organization ${{inputs.owner}} --repository ${{inputs.repository}}
/tmp/codacy-cli-v2 analyze -t ${{inputs.tool}} --format sarif -o ${{inputs.sarif_file_path}} --api-token ${{inputs.api_token}} --provider ${{inputs.provider}} --organization ${{inputs.owner}} --repository ${{inputs.repository}}
else
/tmp/codacy-cli-v2 analyze -t ${{inputs.tool}} --format sarif -o ${{inputs.sarif_file_path}}
fi
Expand Down