diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6eca42a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.github/instructions \ No newline at end of file diff --git a/action.yml b/action.yml index 5866634..aa45524 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,9 @@ runs: echo "Setting up CLI V2" curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh -o /tmp/codacy-cli-v2 chmod +x /tmp/codacy-cli-v2 + 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.registry }}" != "" ]; then /tmp/codacy-cli-v2 install -r ${{ inputs.registry }} else @@ -71,7 +74,11 @@ runs: shell: bash run: | echo "Running the tool" - /tmp/codacy-cli-v2 analyze -t ${{inputs.tool}} --format sarif -o ${{inputs.sarif_file_path}} + 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}} + else + /tmp/codacy-cli-v2 analyze -t ${{inputs.tool}} --format sarif -o ${{inputs.sarif_file_path}} + fi echo "Tool run complete" - name: "Upload the results" shell: bash