From ca0a9d7f0bf1671d4a475ea4654a679862b11fbb Mon Sep 17 00:00:00 2001 From: Mikael Andersson Date: Sun, 21 Dec 2025 08:45:33 +0100 Subject: [PATCH 1/2] feat: add optional working_directory input Add input to control the working directory of the action intended to limit the scope of the action to specific projects working directory --- action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yml b/action.yml index 873e869..d26627a 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,7 @@ outputs: blocker_findings: description: "The number of findings of severity BLOCKER" value: ${{ steps.cc.outputs.blocker }} + runs: using: "composite" steps: @@ -56,6 +60,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 }} @@ -107,6 +112,7 @@ runs: # as it does not need to redownload the images already pulled by the first run - name: Generate HTML Report shell: bash + 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 }} @@ -138,6 +144,7 @@ runs: # 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 }} From 16d57cc795358e9c50674cdca26f96090ccf430e Mon Sep 17 00:00:00 2001 From: Mikael Andersson Date: Sun, 21 Dec 2025 09:05:04 +0100 Subject: [PATCH 2/2] feat: add path to reports as outputs Add outputs html_report and json_report as outputs to the action to enable further ease of use on retrieving reports in follow-up steps --- action.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/action.yml b/action.yml index d26627a..665c4f0 100644 --- a/action.yml +++ b/action.yml @@ -52,6 +52,12 @@ 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" @@ -107,11 +113,13 @@ 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 }} @@ -137,8 +145,10 @@ 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