Initial
All checks were successful
Release / Create Release (push) Successful in 15s
Release / Print Release (push) Successful in 3s

This commit is contained in:
Luke Tainton 2025-03-23 20:45:06 +00:00
commit 162f57b2ff
Signed by: luke
SSH Key Fingerprint: SHA256:D34npKT7UaiT/7gULqu7EPSLWWVAjTjXf4kKfJ/fQBo
8 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,14 @@
name: Conventional Commit
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
jobs:
validate_pr_title:
uses: https://git.tainton.uk/actions/gha-workflows/.gitea/workflows/conventional-commit.yml@main
with:
commit_message: ${{ gitea.event.pull_request.title }}

View File

@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
create_release:
name: Create Release
uses: https://git.tainton.uk/actions/gha-workflows/.gitea/workflows/create-release.yml@main
secrets:
ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
print_release:
name: Print Release
runs-on: ubuntu-latest
needs: create_release
steps:
- run: echo "Created release ${{ needs.create_release.outputs.release_name }}."

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM python:3.11-slim
LABEL maintainer="Luke Tainton <luke@tainton.uk>"
WORKDIR /home
COPY . .
RUN pip install requests
ENTRYPOINT ["python3", "/home/pushover.py"]

10
LICENSE Normal file
View File

@ -0,0 +1,10 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

38
README.md Normal file
View File

@ -0,0 +1,38 @@
# Pushover Action
A [GitHub Action](https://github.com/features/actions) / [Gitea Action](https://docs.gitea.com/usage/actions/overview) to send a message via Pushover.
You can use the Action as follows:
```yaml
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: https://git.tainton.uk/actions/pushover-action@v1.0.0
env:
PUSHOVER_APP_TOKEN: xxx
PUSHOVER_USER_TOKEN: xxx
with:
message: ${{ github.event.head_commit.message }}
```
## Properties
For more info on what a property means, see the Pushover API [documentation](https://pushover.net/api).
| Property | Description | Required? |
| ----------- | --------------------------------------------- | --------- |
| `message` | Message to send | Yes |
| `title` | Message title | No |
| `device` | Registered device to send the message to | No |
| `priority` | Priority of the message | No |
| `sound` | Sound to use when delivering the notification | No |
| `url` | URL to present in the notification | No |
| `url_title` | Button name to use for the URL link | No |

37
action.yml Normal file
View File

@ -0,0 +1,37 @@
name: 'Pushover'
description: 'A GitHub/Gitea Action to send a message via Pushover.'
inputs:
message:
description: 'Message to send'
required: true
device:
description: 'Device to send message to'
required: false
priority:
description: 'Message priority'
required: false
default: '0'
sound:
description: 'Sound to play'
required: false
default: 'pushover'
title:
description: 'Message title'
required: false
url:
description: 'URL to include with message'
required: false
url_title:
description: 'Title for URL'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
args:
- --message=${{ inputs.message }}
- --title=${{ inputs.title }}
- --url=${{ inputs.url }}
- --url_title=${{ inputs.url_title }}
- --device=${{ inputs.device }}
- --priority=${{ inputs.priority }}
- --sound=${{ inputs.sound }}

65
pushover.py Executable file
View File

@ -0,0 +1,65 @@
import os
import argparse
import requests
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('--message', type=str, help='Message text')
parser.add_argument('--title', type=str, help='Message title')
parser.add_argument('--url', type=str, help='Supplementary URL to show with your message')
parser.add_argument('--url_title', type=str, help='title for your supplementary URL, otherwise just the URL is shown')
parser.add_argument('--device', type=str, help='Device name to send the message directly to')
parser.add_argument('--priority', type=str, help='Notification priority (low-to-high: -2 to 1)')
parser.add_argument('--sound', type=str, help='The name of a supported sound (https://pushover.net/api#sounds; custom sounds are supported)')
args = parser.parse_args()
return args
def main():
args = get_args()
token = os.environ['PUSHOVER_APP_TOKEN']
user = os.environ['PUSHOVER_USER_TOKEN']
msg: str = args.message
title: str | None = args.title if args.title else None
url: str | None = args.url if args.url else None
url_title: str | None = args.url_title if args.url_title else None
device: str | None = args.device if args.device else None
priority: str | None = args.priority if args.priority else None
sound: str | None = args.sound if args.sound else None
if not msg:
print('No message provided')
return
payload = {
'token' : token,
'user' : user,
'message' : msg
}
if title:
payload['title'] = title
if url:
payload['url'] = url
if url_title:
payload['url_title'] = url_title
if device:
payload['device'] = device
if priority:
payload['priority'] = priority
if sound:
payload['sound'] = sound
response = requests.post(
url='https://api.pushover.net/1/messages.json',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
data=payload,
timeout=60
)
response.raise_for_status()
print(response.text)
if __name__ == '__main__':
main()

20
renovate.json Normal file
View File

@ -0,0 +1,20 @@
{
"assignAutomerge": true,
"assigneesFromCodeOwners": true,
"dependencyDashboardAutoclose": true,
"extends": ["config:recommended", "docker:enableMajor"],
"ignorePaths": ["**/.archive/**"],
"labels": ["type/dependencies"],
"platformCommit": "enabled",
"rebaseWhen": "behind-base-branch",
"rollbackPrs": true,
"vulnerabilityAlerts": {
"commitMessagePrefix": "[SECURITY] ",
"enabled": true,
"labels": ["security"],
"prCreation": "immediate"
},
"lockFileMaintenance": {
"enabled": true
}
}