Skip to content

Commit

Permalink
redo all
Browse files Browse the repository at this point in the history
Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Dec 20, 2024
1 parent fb5b5a4 commit d7c6cb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
33 changes: 8 additions & 25 deletions .github/workflows/notify-irc.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
#!/bin/bash
# notify.sh
# This script formats the IRC notification message.

echo "COMMITS_JSON: $1"
echo "GITHUB_ACTOR: $2"
echo "GITHUB_REF_NAME: $3"
echo "GITHUB_COMPARE_URL: $4"
COMMITS_JSON="${1:-""}"
ACTOR="${2:-unknown}"
BRANCH="${3:-unknown}"
COMPARE_URL="${4:-unknown}"

# Extract input from environment variables (set by GitHub Actions)
COMMITS_JSON="$1"
ACTOR="$2"
BRANCH="$3"
COMPARE_URL="$4"
commit_count=$(echo "$COMMITS_JSON" | jq 'length' || echo 0)

# Parse the JSON to extract commit titles
COMMIT_TITLES=$(echo "$COMMITS_JSON" | jq -r '.[0:8][] | "\(.id[0:7]) - \(.message | split("\n")[0])"')

# Count the commits
COMMIT_COUNT=$(echo "$COMMITS_JSON" | jq -r 'length')
COMMIT_COUNT=${COMMIT_COUNT:-0} # Default to 0 if jq fails

# Format the message
if [ "$COMMIT_COUNT" -eq 1 ]; then
echo "[openzfs] $ACTOR pushed 1 commit to $BRANCH"
if [ "$commit_count" -eq 0 ]; then
echo "message=[openzfs] $ACTOR pushed no commits to $BRANCH at $COMPARE_URL"
else
echo "[openzfs] $ACTOR pushed $COMMIT_COUNT commits to $BRANCH"
echo "message=[openzfs] $ACTOR pushed $commit_count commits to $BRANCH at $COMPARE_URL"
fi

echo "$COMPARE_URL"

# Print each commit title
echo "$COMMIT_TITLES"

3 changes: 2 additions & 1 deletion .github/workflows/notify-irc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- name: Generate notification message
id: notify
run: |
echo "message=$(.github/workflows/notify-irc.sh "$COMMITS_JSON" "$GITHUB_ACTOR" "$GITHUB_REF_NAME" "$GITHUB_COMPARE_URL")" >> $GITHUB_OUTPUT
echo "message=$(.github/workflows/notify-irc.sh "$COMMITS_JSON" "$GITHUB_ACTOR" "$GITHUB_REF_NAME" "$GITHUB_COMPARE_URL")" | tee -a /tmp/message
printf "%s\n" "message=$(cat /tmp/message)" >> $GITHUB_OUTPUT

- name: Notify IRC
uses: rectalogic/notify-irc@v1
Expand Down

0 comments on commit d7c6cb7

Please sign in to comment.