| .gitattributes | ||
| .gitignore | ||
| action.yml | ||
| CHANGELOG | ||
| cliff.toml | ||
| CODEOWNERS | ||
| Dockerfile | ||
| entrypoint.sh | ||
| LICENSE | ||
| README.md | ||
Ntfy.sh Docker Action
This action allows you to send notifications to Ntfy.sh server.
Contributors
Thanks to the following persons who helped me:
Usage
Here's an example of how to use this action in a workflow file:
Basic usage
name: Ntfy.sh Example Workflow
on: [push]
env:
NTFY_URL: https://ntfy.example.com
NTFY_TOPIC: CI_NOTIFICATIONS
NTFY_MESSAGE: This is an example message
NTFY_TITLE: Notification Title
NTFY_PRIORITY: max
NTFY_ICON: https://ntfy.example.com/icon.png
NTFY_TAGS: smile_cat
NTFY_DELAY: 1m
NTFY_ACTIONS: view, Check action status, https://git.example.com/, clear=true;
NTFY_CLICK: https://example.com/
NTFY_ATTACH: https://example.com/file.txt
NTFY_MARKDOWN: <yes / no>
NTFY_FILENAME: NTFY_ATTACH_FILENAME_OVERRIDE.txt
NTFY_EMAIL: foo@example.com
NTFY_CALL: +1 111-222-3344
NTFY_CACHE: <yes / no>
NTFY_FIREBASE: <yes / no>
NTFY_UNIFIED_PUSH: 1
NTFY_POLL_ID: <private Poll ID>
NTFY_CONTENT_TYPE: text/markdown
jobs:
ntfy:
name: Send Ntfy.sh notification
runs-on: ubuntu-latest
steps:
- name: Send notification
id: send-notification
uses: https://git.paillp.sh/actions/ntfy-action@v2
with:
url: ${{ env.NTFY_URL }}
topic: ${{ env.NTFY_TOPIC }}
message: ${{ env.NTFY_MESSAGE }}
title: ${{ env.NTFY_TITLE }}
priority: ${{ env.NTFY_PRIORITY }}
icon: ${{ env.NTFY_ICON }}
tags: ${{ env.NTFY_TAGS }}
delay: ${{ env.NTFY_DELAY }}
actions: ${{ env.NTFY_ACTIONS }}
click: ${{ env.NTFY_CLICK }}
attach: ${{ env.NTFY_ATTACH }}
markdown: ${{ env.NTFY_MARKDOWN }}
filename: ${{ env.NTFY_FILENAME }}
email: ${{ env.NTFY_EMAIL }}
call: ${{ env.NTFY_CALL }}
cache: ${{ env.NTFY_CACHE }}
firebase: ${{ env.NTFY_FIREBASE }}
unified-push: ${{ env.NTFY_UNIFIED_PUSH }}
poll-id: ${{ env.NTFY_POLL_ID }}
authorization: ${{ secrets.NTFY_AUTHORIZATION }}
content-type: ${{ env.NTFY_CONTENT_TYPE }}
Markdown formatted notifications
name: Ntfy.sh Example Workflow
on: [push]
env:
GIT_URL: https://git.example.com
NTFY_URL: https://ntfy.example.com
NTFY_TOPIC: CI_NOTIFICATIONS
NTFY_MESSAGE: >
'Pushed on **'${{ github.repository }}'**'
NTFY_TITLE: CI Action triggered
NTFY_PRIORITY: default
NTFY_ICON: https://example.com/favicon.ico
NTFY_TAGS: smile_cat
# NTFY_DELAY: 1m
NTFY_ACTIONS: >
'view, Check action status, '${{ GIT_URL }}'/'${{ github.repository }}', clear=true;'
NTFY_CLICK: >
${{ GIT_URL }}'/'${{ github.repository }}
# NTFY_ATTACH: https://example.com/file.txt
NTFY_MARKDOWN: no
# NTFY_FILENAME: NTFY_ATTACH_FILENAME_OVERRIDE.txt
# NTFY_EMAIL: foo@example.com
# NTFY_CALL: +1 111-222-3344
NTFY_CACHE: no
NTFY_FIREBASE: no
NTFY_UNIFIED_PUSH: 1
# NTFY_POLL_ID: <private Poll ID>
NTFY_CONTENT_TYPE: text/markdown
jobs:
ntfy:
name: Send Ntfy.sh notification
runs-on: docker
steps:
- name: Send notification
id: send-notification
uses: https://git.paillp.sh/actions/ntfy-action@v2
with:
url: ${{ env.NTFY_URL }}
topic: ${{ env.NTFY_TOPIC }}
message: ${{ env.NTFY_MESSAGE }}
title: ${{ env.NTFY_TITLE }}
priority: ${{ env.NTFY_PRIORITY }}
icon: ${{ env.NTFY_ICON }}
tags: ${{ env.NTFY_TAGS }}
delay: ${{ env.NTFY_DELAY }}
actions: ${{ env.NTFY_ACTIONS }}
click: ${{ env.NTFY_CLICK }}
attach: ${{ env.NTFY_ATTACH }}
markdown: ${{ env.NTFY_MARKDOWN }}
filename: ${{ env.NTFY_FILENAME }}
email: ${{ env.NTFY_EMAIL }}
call: ${{ env.NTFY_CALL }}
cache: ${{ env.NTFY_CACHE }}
firebase: ${{ env.NTFY_FIREBASE }}
unified-push: ${{ env.NTFY_UNIFIED_PUSH }}
poll-id: ${{ env.NTFY_POLL_ID }}
authorization: ${{ secrets.NTFY_AUTHORIZATION }}
content-type: ${{ env.NTFY_CONTENT_TYPE }}
Using this action with wget
By default, this action uses curl to leverage Ntfy.sh notifications.
However, one can decide to use wget instead by setting the following environment variables
NTFY_COMMAND=wget
NTFY_COMMAND_HEADER=--header
NTFY_COMMAND_POST_DATA=--post-data
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
url |
true |
https://ntfy.sh |
The Ntfy.sh server URL |
topic |
true |
CI |
The Ntfy.sh topic to send notifications to |
message |
true |
Check your forge instance to see build status |
Message displayed in the notification |
title |
true |
CI Job Completed |
Title of the notification |
priority |
true |
default |
Priority of the notification |
icon |
false |
white_check_mark |
Icons of the notification |
tags |
true |
smile_cat |
Tags of the notification |
delay |
false |
N / A |
Delay the notification |
actions |
false |
N / A |
Actions in the notification |
click |
false |
N / A |
Click notification action |
attach |
false |
N / A |
Notification file attachment |
markdown |
false |
N / A |
Notification in Markdown |
filename |
false |
N / A |
Filename of the attached file |
email |
false |
N / A |
Send e-mail notification to address |
call |
false |
N / A |
Phone number to call |
cache |
false |
N / A |
Allow disabling message caching |
firebase |
false |
N / A |
Send to Firebase |
unified-push |
false |
N / A |
Allow using UnifiedPush |
poll-id |
false |
N / A |
Poll ID for iOS push notifications |
authorization |
false |
N / A |
Authentication to the subject |
content-type |
false |
N / A |
Content-Type of the message |
Test Locally
After you've cloned the repository to your local machine or codespace, you'll need to perform some initial setup steps before you can test your action.
Note
You'll need to have a reasonably modern version of Docker handy (e.g. docker engine version 20 or later).
- 🛠️ Build the container
Make sure to replace actions/ntfy-action with an appropriate
label for your container.
docker build -t actions/ntfy-action .
- ✅ Test the container
We strongly recommend that you use an environment file to test the action
with --env-file
Create the environment file with the default values (adjust them if necessary)
cat << EOF > .env.test
NTFY_URL=https://ntfy.example.com
NTFY_TOPIC=CI_NOTIFICATIONS
NTFY_MESSAGE=This is an example message
NTFY_TITLE=Notification Title
NTFY_PRIORITY=max
NTFY_ICON=https://ntfy.example.com/icon.png
NTFY_TAGS=smile_cat
NTFY_DELAY=1m
NTFY_ACTIONS=view, Check action status, https://git.example.com/, clear=true;
NTFY_CLICK=https://example.com/
NTFY_ATTACH=https://example.com/file.txt
NTFY_MARKDOWN=<yes / no>
NTFY_FILENAME=NTFY_ATTACH_FILENAME_OVERRIDE.txt
NTFY_EMAIL=foo@example.com
NTFY_CALL=+1 111-222-3344
NTFY_CACHE=<yes / no>
NTFY_FIREBASE=<yes / no>
NTFY_UNIFIED_PUSH=1
NTFY_POLL_ID=<private Poll ID>
NTFY_CONTENT_TYPE=text/markdown
EOF
Run the container with the created environment file
$ docker run --env-file ./.env.test actions/ntfy-action