3 if [[ -z "$GITHUB_TOKEN" ]]; then
4 echo "The GITHUB_TOKEN is required."
8 FILES_LINK=`jq -r '.pull_request._links.self.href' "$GITHUB_EVENT_PATH"`/files
9 echo "Files = $FILES_LINK"
11 curl $FILES_LINK > files.json
12 FILES_URLS_STRING=`jq -r '.[].raw_url' files.json`
14 readarray -t URLS <<<"$FILES_URLS_STRING"
16 echo "File names: $URLS"
23 curl -LOk --remote-name $i
26 echo "Files downloaded!"
27 echo "Performing checkup:"
32 +whitespace/end_of_line,\
33 +whitespace/blank_line \
36 ./ > cpp-report.txt 2>&1
38 PAYLOAD_CPPLINT=`cat cpp-report.txt`
39 COMMENTS_URL=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.comments_url)
42 echo "Cppcheck errors:"
45 if [[ $PAYLOAD_CPPLINT == *"Total errors found: "* ]]; then
46 OUTPUT+=$'\n**CODING STYLE CHECK**:\n'
48 OUTPUT+="$PAYLOAD_CPPLINT"
52 PAYLOAD=$(echo '{}' | jq --arg body "$OUTPUT" '.body = $body')
54 curl -s -S -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/vnd.github.VERSION.text+json" --data "$PAYLOAD" "$COMMENTS_URL"