diff --git a/action.yml b/action.yml index 873e869..665c4f0 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ branding: color: gray-dark icon: chevrons-up inputs: + working_directory: + description: "The directory to run Code Climate in" + required: false config_file: description: "Optionally provide a path to your codeclimate.yml relative to your project" required: false @@ -49,6 +52,13 @@ outputs: blocker_findings: description: "The number of findings of severity BLOCKER" value: ${{ steps.cc.outputs.blocker }} + html_report: + description: "The HTML report generated by Code Climate (if requested)" + value: ${{ steps.html.outputs.html_report }} + json_report: + description: "The JSON report generated by Code Climate" + value: ${{ steps.cc.outputs.json_report }} + runs: using: "composite" steps: @@ -56,6 +66,7 @@ runs: - name: Code Climate shell: bash id: cc + working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }} env: CC_CONF: ${{ inputs.config_file }} CC_BLOCKERS_ALLOWED: ${{ inputs.blocker_threshold }} @@ -102,11 +113,14 @@ runs: echo "major=$TOTAL_MAJOR" >> $GITHUB_OUTPUT echo "critical=$TOTAL_CRITICAL" >> $GITHUB_OUTPUT echo "blocker=$TOTAL_BLOCKER" >> $GITHUB_OUTPUT + echo "json_report=$PWD/codeclimate-report.json" >> $GITHUB_OUTPUT # Second run purely to get the readable HTML report. The second run is much faster than the first # as it does not need to redownload the images already pulled by the first run - name: Generate HTML Report shell: bash + id: html + working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }} env: CC_CONF: ${{ inputs.config_file }} HTML_REPORT: ${{ inputs.html_report }} @@ -131,13 +145,16 @@ runs: --volume /var/run/docker.sock:/var/run/docker.sock \ --volume /tmp/cc:/tmp/cc \ codeclimate/codeclimate analyze -f html > codeclimate-report.html + echo "html_report=$PWD/codeclimate-report.html" >> $GITHUB_OUTPUT else echo "HTML REPORT not requested, skipping..." + echo "html_report=" >> $GITHUB_OUTPUT fi # Determine the result - name: Parse Result shell: bash + working-directory: ${{ inputs.working_directory && format('{0}/{1}', github.workspace, inputs.working_directory) || github.workspace }} env: CC_BLOCKERS_ALLOWED: ${{ inputs.blocker_threshold }} CC_CRITICAL_ALLOWED: ${{ inputs.critical_threshold }}