Skip to content

Commit

Permalink
fix(script): adjust yamllint_output declaration (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
beiertu-mms authored Mar 13, 2023
1 parent c85ba57 commit fdef6bc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/yaml_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ function yaml_lint {

# gather output
echo "lint: info: yamllint on ${yamllint_file_or_dir}."
lint_output=$(yamllint ${yamllint_strict} ${yamllint_config_filepath} ${yamllint_config_datapath} ${yamllint_format} ${yamllint_file_or_dir})
yamllint ${yamllint_strict} ${yamllint_config_filepath} ${yamllint_config_datapath} ${yamllint_format} ${yamllint_file_or_dir} > lint_result.txt
lint_exit_code=${?}

# exit code 0 - success
if [ ${lint_exit_code} -eq 0 ];then
lint_comment_status="Success"
echo "lint: info: successful yamllint on ${yamllint_file_or_dir}."
echo "${lint_output}"
cat lint_result.txt
echo
fi

# exit code !0 - failure
if [ ${lint_exit_code} -ne 0 ]; then
lint_comment_status="Failed"
echo "lint: error: failed yamllint on ${yamllint_file_or_dir}."
echo "${lint_output}"
cat lint_result.txt
echo
fi

Expand All @@ -29,7 +29,7 @@ function yaml_lint {
<details><summary>Show Output</summary>
\`\`\`
${lint_output}
$(cat lint_result.txt)
\`\`\`
</details>
Expand All @@ -42,7 +42,9 @@ ${lint_output}
echo "${lint_payload}" | curl -s -S -H "Authorization: token ${GITHUB_ACCESS_TOKEN}" --header "Content-Type: application/json" --data @- "${lint_comment_url}" > /dev/null
fi

echo "yamllint_output=${lint_output}" >> $GITHUB_OUTPUT
echo "yamllint_output<<EOF" >> "$GITHUB_OUTPUT"
cat lint_result.txt >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
exit ${lint_exit_code}
}

0 comments on commit fdef6bc

Please sign in to comment.