From b0d7c6c1577cd18710b90e584acab35402e0275e Mon Sep 17 00:00:00 2001 From: eikendev Date: Tue, 31 Mar 2020 19:22:19 +0200 Subject: [PATCH] Initialize repository --- Dockerfile | 7 +++++++ LICENSE | 7 +++++++ README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ action.yml | 30 +++++++++++++++++++++++++++++ entrypoint.sh | 17 +++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27bbfba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM curlimages/curl:latest + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..33d80c7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +ISC License (ISC) + +Copyright 2020 eikendev + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..83b21c8 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Gotify Notification Action + +This action allows you to send push notifications via [Gotify](https://gotify.net/). +Gotify is an open-source push notification server. + +## Inputs + +### `notification_title` + +**Required** The title of the Gotify notification. + +### `notification_message` + +**Required** The message of the Gotify notification. Default `""`. + +### `notification_priority` + +**Required** The priority of the Gotify notification. Default `4`. + +## Outputs + +This action has no outputs. + +## Secrets + +### `gotify_api_base` + +**Required** The HTTP endpoint where the Gotify API is exposed. + +### `gotify_app_token` + +**Required** The token of the Gotify application. + +## Usage + +Create a file `.github/workflows/main.yml` in your repository with the following contents. + +```yaml +name: Gotify Notification +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Gotify Notification + uses: eikendev/action-gotify@master + env: + gotify_api_base: ${{ secrets.gotify_api_base }} + gotify_app_token: ${{ secrets.gotify_app_token }} + notification_title: 'Build Complete' + notification_message: 'Your build was completed.' +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..ae3ed6b --- /dev/null +++ b/action.yml @@ -0,0 +1,30 @@ +name: 'Gotify Notification' +description: 'Send a notification via Gotify' +branding: + icon: 'bell' + color: 'blue' +inputs: + gotify_api_base: + description: 'The HTTP endpoint where the Gotify API is exposed' + required: true + gotify_app_token: + description: 'The token of the Gotify application' + required: true + notification_title: + description: 'The title of the Gotify notification' + required: true + notification_message: + description: 'The message of the Gotify notification' + default: '' + notification_priority: + description: 'The priority of the Gotify notification' + default: 4 +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.gotify_api_base }} + - ${{ inputs.gotify_app_token }} + - ${{ inputs.notification_title }} + - ${{ inputs.notification_message }} + - ${{ inputs.notification_priority }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..1d19611 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +if [ $# -ne 5 ]; then + printf "%s\n" "Usage: $0 " >&2 + exit 1 +fi + +gotify_api_base="$1" +gotify_app_token="$2" +notification_title="$3" +notification_message="$4" +notification_priority="$5" + +curl "$gotify_api_base/message?token=$gotify_app_token" \ + -F "title=$notification_title" \ + -F "message=$notification_message" \ + -F "priority=$notification_priority"