Skip to content

Commit e816b53

Browse files
committed
leaderboard: fix bugs
The `leaderboard-fetch.sh` exit status didn't propagate to `leaderboard-replace.sh`, so the latter wrote error messages into the README. Thus we're now writing error messages to stderr, and don't use export, so that the exit code becomes visible. Further, the branch in `leaderboard.yml` went the wrong way, we called `git commit` when there were no changes, so this commit now adds the negation.
1 parent 958e530 commit e816b53

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

.github/workflows/leaderboard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Commit and Push changes
2424
run: |
2525
set -e
26-
if git diff --no-patch --exit-code README.md; then
26+
if ! git diff --no-patch --exit-code README.md; then
2727
git config --global user.name "${GITHUB_ACTOR}"
2828
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
2929
git commit -am "README.md: update leaderboard" \

leaderboard-fetch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -o pipefail
55
aoc_year=2024
66
export aoc_username="fxnn"
77

8-
[ -z "${AOC_SESSION_COOKIE}" ] && { echo "ERROR: missing AOC_SESSION_COOKIE"; exit 1; }
9-
[ -z "${AOC_LEADERBOARD_ID}" ] && { echo "ERROR: missing AOC_LEADERBOARD_ID"; exit 1; }
8+
[ -z "${AOC_SESSION_COOKIE}" ] && { echo "ERROR: missing AOC_SESSION_COOKIE" >&2; exit 1; }
9+
[ -z "${AOC_LEADERBOARD_ID}" ] && { echo "ERROR: missing AOC_LEADERBOARD_ID" >&2; exit 1; }
1010

1111
curl \
1212
-sS \

leaderboard-replace.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -e
33

4-
export leaderboard="$(./leaderboard-fetch.sh)"
4+
leaderboard="$(./leaderboard-fetch.sh)"
55

6-
awk \
6+
awk -v leaderboard="${leaderboard}" \
77
'
88
BEGIN {
99
isLeaderboard="false" ;
@@ -22,7 +22,7 @@ awk \
2222
}
2323
isLeaderboard=="true" && isLeaderboardPrinted=="false" {
2424
print "" ;
25-
print "> " ENVIRON["leaderboard"] ;
25+
print "> " leaderboard ;
2626
print "" ;
2727
isLeaderboardPrinted="true" ;
2828
next ;

0 commit comments

Comments
 (0)