9 Commits

Author SHA1 Message Date
Tyler Perkins
528a6510eb Make curl u param more dynamic 2022-12-16 21:21:51 -05:00
Tyler Perkins
7ab1061904 Add Icon and Attachment support (#9) 2022-12-16 21:14:37 -05:00
Tyler Perkins
4bab19d289 Add Documentation (#7)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone

* Fix typo in alpine name

* Add ntfy service to drone

* Update dockerfile

* Fix entry point in Dockerfile

* Update README with options
2022-12-16 20:12:40 -05:00
Tyler Perkins
0ca6b05d20 Fix Dockerfile entry point (#6)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone

* Fix typo in alpine name

* Add ntfy service to drone

* Update dockerfile

* Fix entry point in Dockerfile
2022-12-16 19:59:54 -05:00
Tyler Perkins
cd40495ff4 Fix docker file (#5)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone

* Fix typo in alpine name

* Add ntfy service to drone

* Update dockerfile
2022-12-16 19:54:31 -05:00
Tyler Perkins
28b4caa7aa Add ntfy to drone (#4)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone

* Fix typo in alpine name

* Add ntfy service to drone
2022-12-16 19:51:31 -05:00
Tyler Perkins
e93440e203 Fix typo (#3)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone

* Fix typo in alpine name
2022-12-16 19:41:26 -05:00
Tyler Perkins
3e56688254 Add dronefile (#2)
* Add Dockerfile and main.sh

* Add base settings for now

* Add drone
2022-12-16 19:39:04 -05:00
Tyler Perkins
311b767a7d Add basic functions (#1)
* Add Dockerfile and main.sh

* Add base settings for now
2022-12-16 19:31:55 -05:00
4 changed files with 68 additions and 7 deletions

View File

@@ -15,3 +15,14 @@ steps:
when: when:
branch: branch:
- main - main
- name: notify
image: clortox/drone-ntfy
settings:
URL: https://ntfy.clortox.com
USERNAME: drone
PASSWORD:
from_secret: ntfy_password
TOPIC: drone-builds
MESSAGE: Drone-ntfy has finished building!
CLICK: https://drone.clortox.com/tyler/drone-ntfy
TITLE: Drone (drone-ntfy)

View File

@@ -1,5 +1,5 @@
FROM apline FROM alpine
ADD main.sh /bin/ COPY main.sh /bin/
RUN chmod +x /bin/main.sh RUN chmod +x /bin/main.sh
RUN apk -Uuv add curl ca-certificates RUN apk -Uuv add curl ca-certificates bash
ENTRYPOINT /bin/main.sh ENTRYPOINT bash /bin/main.sh

View File

@@ -2,5 +2,44 @@
A [Drone](https://drone.io) plugin for ntfy. A [Drone](https://drone.io) plugin for ntfy.
## Example
The following is an example pipeline where we only send a notification
```yaml
steps:
- name:
image: clortox/drone-ntfy
settings:
URL: https://ntfy.clortox.com
USERNAME: drone
PASSWORD:
from_secret: ntfy_password
TOPIC: drone-builds
MESSAGE: Drone build done!
CLICK: https://drone.clortox.com/tyler/drone-ntfy
TITLE: Drone (Drone-ntfy)
```
A living, breathing example of this is in this repository's [drone file](.drone.yml).
## Options
There are several options that you can configure when sending the notification.
Note that the `ntfy Name` is the name you will use in the settings section of
your configuration.
| ntfy Name | Container Environment Variable | Default Value | Description |
| -------- | ------ | ----- | ----------- |
| Priority | PLUGIN_PRIORITY | N/A | Notification Priority |
| Title | PLUGIN_TITLE | N/A | Title of the notification |
| Tags | PLUGIN_TAGS | N/A | Emojis on the notification |
| Click | PLUGIN_CLICK | N/A | URL to navigate to if the user clicks the notification |
| Attach (TODO) | PLUGIN_ATTACH | N/A | URL or localfile to attach |
| Icon (TODO) | PLUGIN_ICON | N/A | Icon to display |
| URL | PLUGIN_URL | ntfy.sh | URL to send the notification to |
| Topic | PLUGIN_TOPIC | drone-notifications | The notification top to send this to |
| Message | PLUGIN_MESSAGE | Pipeline Finished! | The body of the notification |
| Username | PLUGIN_USERNAME | N/A | The username to authenticate with |
| Password | PLUGIN_PASSWORD | N/A | The password to authenticate with |

17
main.sh
View File

@@ -6,7 +6,6 @@ Priority=${PLUGIN_PRIORITY:-}
Title=${PLUGIN_TITLE:-} Title=${PLUGIN_TITLE:-}
Tags=${PLUGIN_TAGS:-} Tags=${PLUGIN_TAGS:-}
Click=${PLUGIN_CLICK:-} Click=${PLUGIN_CLICK:-}
Attach=${PLUGIN_ATTACH:-} Attach=${PLUGIN_ATTACH:-}
Icon=${PLUGIN_ICON:-} Icon=${PLUGIN_ICON:-}
@@ -17,6 +16,10 @@ Message=${PLUGIN_MESSAGE:-Pipeline finished!}
Username=${PLUGIN_USERNAME:-} Username=${PLUGIN_USERNAME:-}
Password=${PLUGIN_PASSWORD:-} Password=${PLUGIN_PASSWORD:-}
if [[ ! -z $Username ]] || [[ ! -z $Password ]]; then
UParam="-u $Username:$Password"
fi
if [[ ! -z $Priority ]]; then if [[ ! -z $Priority ]]; then
Priority="-H Priority:$Priority" Priority="-H Priority:$Priority"
fi fi
@@ -33,5 +36,13 @@ if [[ ! -z $Click ]]; then
Click="-H Click:$Click" Click="-H Click:$Click"
fi fi
curl $Priority $Title $Tags $Click -u $Username:$Password -d "$Message" $URL/$Topic if [[ ! -z $Attach ]]; then
#echo curl $Priority $Title $Tags $Click -u $Username:$Password -d "$Message" $URL/$Topic Attach="-H Attach:$Attach"
fi
if [[ ! -z $Icon ]]; then
Icon="-H Icon:$Icon"
fi
curl $Priority $Title $Tags $Click $Attach $Icon $UParam -d "$Message" $URL/$Topic
#curl $Priority $Title $Tags $Click $Attach $Icon $UParam -d "$Message" $URL/$Topic