diff --git a/action.yml b/action.yml index 4174fb7..99fd048 100644 --- a/action.yml +++ b/action.yml @@ -29,3 +29,20 @@ runs: - run: | "${{ github.action_path }}/check.sh" "${{ inputs.clang-format-version }}" "${{ inputs.check-path }}" "${{ inputs.fallback-style }}" "${{ inputs.exclude-regex }}" shell: bash + - name: Save PR head commit SHA + if: failure() && github.event_name == 'pull_request' + shell: bash + run: | + SHA="${{ github.event.pull_request.head.sha }}" + echo "SHA=$SHA" >> $GITHUB_ENV + - name: Save latest commit SHA if not PR + if: failure() && github.event_name != 'pull_request' + shell: bash + run: echo "SHA=${{ github.sha }}" >> $GITHUB_ENV + + - name: Report failure in job summary + if: failure() + run: | + DEEPLINK="https://github.com/${{ github.repository }}/commit/${{ env.SHA }}" + echo -e "Format check failed on commit [${GITHUB_SHA:0:8}]($DEEPLINK) with files:\n$(<$GITHUB_WORKSPACE/failing-files.txt)" >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/check.sh b/check.sh index 5dff783..1fbeb35 100755 --- a/check.sh +++ b/check.sh @@ -29,6 +29,10 @@ format_diff() { local format_status="$?" if [[ ${format_status} -ne 0 ]]; then + # Append Markdown-bulleted monospaced filepath of failing file to + # summary file. + echo "* \`$filepath\`" >>failing-files.txt + echo "Failed on file: $filepath" >&2 echo "$local_format" >&2 exit_code=1 # flip the global exit code