generated from gotify/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new gotify-to-telegram plugin (#1)
Adds a new Gotify plugin for forwarding messages to Telegram with the following features: - Support for forwarding messages to multiple telegram bots/chat ids - Configurable message formatting options per bot - Configuration via environment variables or yaml config file via Gotify UI
- Loading branch information
1 parent
bcbff4c
commit 37e0a46
Showing
26 changed files
with
3,570 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"], | ||
"rules": { | ||
"scope-case": [2, "always", "lower-case"], | ||
"subject-case": [2, "never", ["start-case", "pascal-case", "upper-case"]] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
TG_PLUGIN__GOTIFY_CLIENT_TOKEN=abc123 | ||
TG_PLUGIN__GOTIFY_URL="http://localhost:80" | ||
TG_PLUGIN__LOG_LEVEL="debug" | ||
TG_PLUGIN__TELEGRAM_DEFAULT_CHAT_IDS="1234567890,9876543210" | ||
TG_PLUGIN__TELEGRAM_DEFAULT_BOT_TOKEN="1234567890:abcdefghijklmn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
|
||
- name: Download tools | ||
run: make download-tools | ||
|
||
- name: Run tests | ||
run: make test | ||
|
||
create-tag: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
outputs: | ||
new_version: ${{ steps.tag_version.outputs.new_version }} | ||
tag: ${{ steps.tag_version.outputs.new_tag }} | ||
supported_versions: ${{ steps.versions.outputs.versions }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Read versions file | ||
id: versions | ||
run: | | ||
VERSIONS=$(cat SUPPORTED_GOTIFY_VERSIONS.txt | jq -R -s -c 'split("\n")[:-1]') | ||
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT | ||
- name: Create Tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
default_bump: patch | ||
|
||
build: | ||
needs: create-tag | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
gotify_version: ${{ fromJson(needs.create-tag.outputs.supported_versions) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
|
||
- name: Download tools | ||
run: make download-tools | ||
|
||
- name: Build plugin | ||
run: >- | ||
make | ||
GOTIFY_VERSION="${{ matrix.gotify_version }}" | ||
FILE_SUFFIX="-v${{ needs.create-tag.outputs.new_version }}-for-gotify-${{ matrix.gotify_version }}" | ||
LD_FLAGS="-X main.Version=${{ needs.create-tag.outputs.new_version }}" | ||
build | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: plugin-${{ matrix.gotify_version }} | ||
path: build/*.so | ||
|
||
release: | ||
needs: | ||
- create-tag | ||
- build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Generate version list | ||
id: versions | ||
run: | | ||
version_list=$(cat SUPPORTED_GOTIFY_VERSIONS.txt | sed 's/^/- /') | ||
echo "version_list<<EOF" >> $GITHUB_ENV | ||
echo "$version_list" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Download all artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Display structure of downloaded files | ||
run: ls -R | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ needs.create-tag.outputs.tag }} | ||
name: Release ${{ needs.create-tag.outputs.tag }} | ||
files: plugin-*/gotify-to-telegram-*.so | ||
generate_release_notes: true | ||
body: | | ||
## Supported Gotify Versions | ||
${{ env.version_list }} | ||
## Installation | ||
Download the appropriate plugin file for your architecture and Gotify version: | ||
- AMD64: `gotify-to-telegram-linux-amd64-v${{ needs.create-tag.outputs.new_version }}-for-gotify-*.so` | ||
- ARM64: `gotify-to-telegram-linux-arm64-v${{ needs.create-tag.outputs.new_version }}-for-gotify-*.so` | ||
- ARM7: `gotify-to-telegram-linux-arm-7-v${{ needs.create-tag.outputs.new_version }}-for-gotify-*.so` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: PR Title Lint | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
- reopened | ||
|
||
permissions: | ||
pull-requests: read | ||
statuses: write | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/action-semantic-pull-request@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
types: | | ||
feat | ||
fix | ||
docs | ||
style | ||
refactor | ||
perf | ||
test | ||
build | ||
ci | ||
chore | ||
revert | ||
# Configure that a scope must always be provided | ||
requireScope: false | ||
# Configure additional validation for the subject based on a regex. | ||
# This example ensures the subject starts with lowercase. | ||
subjectPattern: ^(?![A-Z]).+$ | ||
# If `subjectPattern` is configured, you can use this property to override | ||
# the default error message that is shown when the pattern doesn't match. | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" | ||
didn't match the configured pattern. Please ensure that the subject | ||
starts with a lowercase character. | ||
# For work-in-progress PRs you can typically use draft pull requests | ||
# from GitHub. However, private repositories on the free plan don't have | ||
# this option and therefore this action allows you to opt-in to using the | ||
# special "[WIP]" prefix to indicate this state. This will avoid the | ||
# validation of the PR title and the pull request checks remain pending. | ||
# Note that a second check will be reported if this is enabled. | ||
wip: true | ||
# When using "Squash and merge" on a PR with only one commit, GitHub | ||
# will suggest using that commit message instead of the PR title for the | ||
# merge commit, and it's easy to commit this by mistake. Enable this option | ||
# to also validate the commit message for one-commit PRs. | ||
validateSingleCommit: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
|
||
- name: Download tools | ||
run: make download-tools | ||
|
||
- name: Run tests | ||
run: make test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
.idea | ||
vendor | ||
build | ||
*.so | ||
*.so | ||
.DS_Store | ||
|
||
.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MD013: | ||
line_length: 120 | ||
heading_line_length: 120 | ||
code_block_line_length: 120 | ||
code_blocks: true | ||
tables: true | ||
headings: true | ||
strict: false | ||
stern: false |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.