Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bark.sh #5229

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: build and push the image
run: |
DOCKER_IMAGE=neilpang/acme.sh
DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/acme.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, reverted it.


if [[ $GITHUB_REF == refs/tags/* ]]; then
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
Expand Down
103 changes: 90 additions & 13 deletions notify/bark.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
#!/usr/bin/env sh

#Support iOS Bark Notification
# Support iOS Bark Notification

#BARK_API_URL="https://api.day.app/xxxx"
#BARK_SOUND="yyyy"
#BARK_GROUP="zzzz"
# Every parameter explained: https://github.com/Finb/bark-server/blob/master/docs/API_V2.md#push

# subject content statusCode
# BARK_API_URL="https://api.day.app/xxxx" (required)
# BARK_GROUP="ACME" (optional)
# BARK_SOUND="alarm" (optional)
# BARK_LEVEL="active" (optional)
# BARK_BADGE=0 (optional)
# BARK_AUTOMATICALLYCOPY="1" (optional)
# BARK_COPY="My clipboard Content" (optional)
# BARK_ICON="https://example.com/icon.png" (optional)
# BARK_ISARCHIVE="1" (optional)
# BARK_URL="https://example.com" (optional)

# subject content statusCode
bark_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_statusCode="$3" # 0: success, 1: error, 2: skipped
_debug "_subject" "$_subject"
_debug "_content" "$_content"
_debug "_statusCode" "$_statusCode"

_content=$(echo "$_content" | _url_encode)
_subject=$(echo "$_subject" | _url_encode)

BARK_API_URL="${BARK_API_URL:-$(_readaccountconf_mutable BARK_API_URL)}"
if [ -z "$BARK_API_URL" ]; then
BARK_API_URL=""
_err "You didn't specify a Bark API URL BARK_API_URL yet."
_err "You can download Bark from App Store and get yours."
return 1
fi
_saveaccountconf_mutable BARK_API_URL "$BARK_API_URL"

BARK_SOUND="${BARK_SOUND:-$(_readaccountconf_mutable BARK_SOUND)}"
_saveaccountconf_mutable BARK_SOUND "$BARK_SOUND"

BARK_GROUP="${BARK_GROUP:-$(_readaccountconf_mutable BARK_GROUP)}"
if [ -z "$BARK_GROUP" ]; then
BARK_GROUP="ACME"
Expand All @@ -35,10 +43,79 @@ bark_send() {
_saveaccountconf_mutable BARK_GROUP "$BARK_GROUP"
fi

_content=$(echo "$_content" | _url_encode)
_subject=$(echo "$_subject" | _url_encode)
BARK_SOUND="${BARK_SOUND:-$(_readaccountconf_mutable BARK_SOUND)}"
if [ -n "$BARK_SOUND" ]; then
_saveaccountconf_mutable BARK_SOUND "$BARK_SOUND"
fi

BARK_LEVEL="${BARK_LEVEL:-$(_readaccountconf_mutable BARK_LEVEL)}"
if [ -n "$BARK_LEVEL" ]; then
_saveaccountconf_mutable BARK_LEVEL "$BARK_LEVEL"
fi

BARK_BADGE="${BARK_BADGE:-$(_readaccountconf_mutable BARK_BADGE)}"
if [ -n "$BARK_BADGE" ]; then
_saveaccountconf_mutable BARK_BADGE "$BARK_BADGE"
fi

BARK_AUTOMATICALLYCOPY="${BARK_AUTOMATICALLYCOPY:-$(_readaccountconf_mutable BARK_AUTOMATICALLYCOPY)}"
if [ -n "$BARK_AUTOMATICALLYCOPY" ]; then
_saveaccountconf_mutable BARK_AUTOMATICALLYCOPY "$BARK_AUTOMATICALLYCOPY"
fi

BARK_COPY="${BARK_COPY:-$(_readaccountconf_mutable BARK_COPY)}"
if [ -n "$BARK_COPY" ]; then
_saveaccountconf_mutable BARK_COPY "$BARK_COPY"
fi

BARK_ICON="${BARK_ICON:-$(_readaccountconf_mutable BARK_ICON)}"
if [ -n "$BARK_ICON" ]; then
_saveaccountconf_mutable BARK_ICON "$BARK_ICON"
fi

BARK_ISARCHIVE="${BARK_ISARCHIVE:-$(_readaccountconf_mutable BARK_ISARCHIVE)}"
if [ -n "$BARK_ISARCHIVE" ]; then
_saveaccountconf_mutable BARK_ISARCHIVE "$BARK_ISARCHIVE"
fi

BARK_URL="${BARK_URL:-$(_readaccountconf_mutable BARK_URL)}"
if [ -n "$BARK_URL" ]; then
_saveaccountconf_mutable BARK_URL "$BARK_URL"
fi

_params=""

if [ -n "$BARK_SOUND" ]; then
_params="$_params&sound=$BARK_SOUND"
fi
if [ -n "$BARK_GROUP" ]; then
_params="$_params&group=$BARK_GROUP"
fi
if [ -n "$BARK_LEVEL" ]; then
_params="$_params&level=$BARK_LEVEL"
fi
if [ -n "$BARK_BADGE" ]; then
_params="$_params&badge=$BARK_BADGE"
fi
if [ -n "$BARK_AUTOMATICALLYCOPY" ]; then
_params="$_params&automaticallyCopy=$BARK_AUTOMATICALLYCOPY"
fi
if [ -n "$BARK_COPY" ]; then
_params="$_params&copy=$BARK_COPY"
fi
if [ -n "$BARK_ICON" ]; then
_params="$_params&icon=$BARK_ICON"
fi
if [ -n "$BARK_ISARCHIVE" ]; then
_params="$_params&isArchive=$BARK_ISARCHIVE"
fi
if [ -n "$BARK_URL" ]; then
_params="$_params&url=$BARK_URL"
fi

_params=$(echo "$_params" | sed 's/^&//') # remove leading '&' if exists

response="$(_get "$BARK_API_URL/$_subject/$_content?sound=$BARK_SOUND&group=$BARK_GROUP")"
response="$(_get "$BARK_API_URL/$_subject/$_content?$_params")"

if [ "$?" = "0" ] && _contains "$response" "success"; then
_info "Bark API fired success."
Expand Down