-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jorgen Lundman <[email protected]>
- Loading branch information
Showing
2 changed files
with
10 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters