Fix - Made the results.json wellformed from cron

Fixed the results.json to be wellformed from the cron job.

Changed the docker image from gsutil to cloudsdk:slim to `sed` binary
which is being used with the cron.sh
This commit is contained in:
naveen 2021-03-11 21:27:55 +00:00 committed by Naveen
parent b8768a0eb3
commit 0eaa4ff3d0
2 changed files with 5 additions and 2 deletions

View File

@ -26,7 +26,7 @@ ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /out/scorecard .
FROM gcr.io/cloud-builders/gsutil
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim
COPY --from=build /out/scorecard /
COPY ./cron/ /cron/
ENTRYPOINT [ "/scorecard" ]

View File

@ -17,7 +17,7 @@ SOURCE="${BASH_SOURCE[0]}"
input=$(dirname "$SOURCE")/projects.txt
output=$(date +"%m-%d-%Y").json
touch "$output"
curl https://raw.githubusercontent.com/ossf/scorecard/main/cron/projects.txt >projects.txt
echo "{ \"results\": [" >> "$output"
# sort and uniqify these, in case there are duplicates
# shellcheck disable=SC2002
@ -28,7 +28,10 @@ while read -r proj; do
fi
echo "$proj"
../scorecard --repo="$proj" --show-details --format=json >> "$output"
echo "," >> "$output"
done <<< "$projects"
sed -i '$d' "$output" # removing the trailing comma which will be last line.
echo "]}" >> "$output"
gsutil cp "$output" gs://"$GCS_BUCKET"
# Also copy the most recent run into a "latest.json" file