diff options
author | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
commit | 7400e108286a0fceacdac63b125fdc924c2dd50c (patch) | |
tree | 4849176606778477ead8a9ded4c9ff43bf4a8feb /aux/ci/report.sh | |
parent | servers/nixvps/configuration.nix: Serve Git repositories from NGINX, remove G... (diff) | |
download | server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.gz server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.xz |
aux/: Update
Diffstat (limited to 'aux/ci/report.sh')
-rwxr-xr-x | aux/ci/report.sh | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/aux/ci/report.sh b/aux/ci/report.sh index 65d3335..1aa41a0 100755 --- a/aux/ci/report.sh +++ b/aux/ci/report.sh @@ -1,23 +1,47 @@ #!/bin/sh set -eu -PROJECT_UC="$1" +TLD="$(cat aux/tld.txt)" +. aux/lib.sh + +while getopts 'n:o:' flag; do + case "$flag" in + n) + PROJECT="$OPTARG" + ;; + o) + OUTDIR="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +assert_arg() { + if [ -z "$1" ]; then + echo "Missing $2" >&2 + exit 2 + fi +} + +assert_arg "${PROJECT:-}" '-n PROJECT' +assert_arg "${OUTDIR:-}" '-o OUTDIR' PASS='✅' FAIL='❌' -mkdir -p public/ci-logs public/ci-data +mkdir -p "$OUTDIR/ci-logs" "$OUTDIR/ci-data" -OUT="$(mktemp)" +OUT="$(mkstemp)" chmod 644 "$OUT" -git fetch origin refs/notes/*:refs/notes/* ||: - for c in $(git notes list | cut -d\ -f2); do DATA="$(git notes --ref=refs/notes/ci-data show "$c")" FILENAME="$(echo "$DATA" | cut -d\ -f2)" - echo "$DATA" > "public/ci-data/$FILENAME" - git notes --ref=refs/notes/ci-logs show "$c" > "public/ci-logs/$FILENAME" + echo "$DATA" > "$OUTDIR/ci-data/$FILENAME" + git notes --ref=refs/notes/ci-logs show "$c" > "$OUTDIR/ci-logs/$FILENAME" done cat <<EOF >> "$OUT" @@ -27,6 +51,7 @@ cat <<EOF >> "$OUT" <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="icon" type="image/svg+xml" href="favicon.svg" /> + <title>CI logs for $PROJECT</title> <style> pre { @@ -36,12 +61,12 @@ cat <<EOF >> "$OUT" </head> <body> <h1> - CI logs for $PROJECT_UC + CI logs for <a href="https://$TLD/$PROJECT/en/">$PROJECT</a> </h1> <ul> EOF -for f in $(find public/ci-data/ -type f | LANG=C.UTF-8 sort -r); do +for f in $(find "$OUTDIR/ci-data/" -type f | LANG=C.UTF-8 sort -r); do DATA="$(cat "$f")" STATUS="$(echo "$DATA" | cut -d\ -f1)" FILENAME="$(echo "$DATA" | cut -d\ -f2)" @@ -67,4 +92,4 @@ cat <<EOF >> "$OUT" </html> EOF -mv "$OUT" public/ci.html +mv "$OUT" "$OUTDIR/ci.html" |