Skip to content

Commit

Permalink
Don't do nonzero exit status in check-latest-note script
Browse files Browse the repository at this point in the history
GH Actions doesn't like this.
  • Loading branch information
brookback committed Jan 30, 2024
1 parent d68f9df commit 17b8d37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
BUILD_ARTIFACT: johan.im-build
BUILD_FOLDER: build
MASTODON_LOG_FILE: ../.mastodon-notes
NOTES_DIR: ../src/notes

jobs:
build:
Expand Down Expand Up @@ -83,9 +82,10 @@ jobs:
- name: Check if latest note is already posted
id: mastodon_note_check
run: |
./script/check-mastodon-note.sh
status=$(echo $?)
[ "$status" == "0" ] && echo "do_post=true" >> "$GITHUB_OUTPUT"
latest=$(./script/check-mastodon-note.sh)
echo "Latest note is $latest"
[ ! -z "$latest" ] && echo "do_post=true" >> "$GITHUB_OUTPUT"
echo "latest_unposted=$latest" >> "$GITHUB_OUTPUT"
post_mastodon:
name: Send latest micro post to Mastodon
Expand All @@ -112,13 +112,11 @@ jobs:

- name: Write to log
run: |
# 2022-01-04-09-37.md -> 202201040937
latest=$(ls -r1 "$DIR" | grep -v "_" | head -n 1 | sed -e "s/-//g" | cut -f 1 -d ".")
echo "$latest" >> $MASTODON_LOG_FILE
echo "$LATEST_UNPOSTED" >> $MASTODON_LOG_FILE
cat "$MASTODON_LOG_FILE"
env:
MASTODON_LOG_FILE: ${{ env.MASTODON_LOG_FILE }}
DIR: ${{ env.NOTES_DIR }}
LATEST_UNPOSTED: ${{ needs.check_latest_note.outputs.latest_unposted }}

- name: Commit and push posted notes
run: |
Expand Down
7 changes: 2 additions & 5 deletions script/check-mastodon-note.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ MASTODON_LIST=".mastodon-notes"
# 2022-01-04-09-37.md -> 202201040937
LATEST=$(ls -r1 "$DIR" | grep -v "_" | head -n 1 | sed -e "s/-//g" | cut -f 1 -d ".")

echo "Latest note is $LATEST"

case `cat "$MASTODON_LIST" | grep -Fxq "$LATEST" >/dev/null; echo $?` in
0)
# found
echo "Found note $LATEST in $MASTODON_LIST. Do nothing."
exit 2
exit 0
;;
1)
# not found, continue
echo "Note $LATEST not in $MASTODON_LIST"
echo "$LATEST"
exit 0
;;
*)
Expand Down

0 comments on commit 17b8d37

Please sign in to comment.