mirror of
https://github.com/appleboy/telegram-action.git
synced 2026-06-12 14:37:58 +00:00
Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 221e6b6849 | |||
| 9177cafddc | |||
| 65a1d3c2f9 | |||
| a77dd3e42f | |||
| 2e9996f96e | |||
| 2efd23283a | |||
| a5d86cddbc | |||
| f384cb685b | |||
| ed144893ba | |||
| beaf02496b | |||
| 6ecbcc43b0 | |||
| dc870f34e9 | |||
| 6cdf58fd81 | |||
| 1ecd8d50e4 | |||
| 9e5e0be372 | |||
| 0e7bbc5ef7 | |||
| 3295af7b78 | |||
| 12a87fd2ec | |||
| ec18563cbb | |||
| d23549b68a | |||
| 18c4142dfa | |||
| c05923bdec | |||
| 50dd6d184f | |||
| 68616a84f7 | |||
| f501e27814 | |||
| 867844f8a4 | |||
| abd0142ad9 | |||
| 363157132e | |||
| d0bf9f621b | |||
| 1ac4b1171b | |||
| 845086369b | |||
| 268d7f7856 | |||
| 7ba2054f08 | |||
| d04c916137 | |||
| df78a5d925 | |||
| 94223af513 | |||
| deae8157b2 | |||
| 74d1289afd | |||
| 65a4c9fc42 | |||
| ee6f548104 | |||
| 62444e6582 | |||
| 406cbeb82a | |||
| a5e94a4245 | |||
| 40cbdc99a4 | |||
| ac4245365c | |||
| 06cc7371ce | |||
| b535a89bc8 | |||
| 696643cdf6 | |||
| bd65e6f3ea | |||
| 040616c1f8 | |||
| a10dfd2766 | |||
| c83985c531 | |||
| 2b5a500551 | |||
| fdf386abfa | |||
| 4e83d473fc | |||
| a14c43a7be | |||
| 82f08879c5 | |||
| f622f39b03 | |||
| 89073d4db2 | |||
| 7952082356 | |||
| 4dbe08d34a | |||
| ffc52f02f2 | |||
| 8920bdffe3 | |||
| d1f5f0e4e9 | |||
| cba7edda6f | |||
| 868c74871e | |||
| 3fb31034d1 | |||
| d753c01b96 | |||
| 6399a5ed49 | |||
| 0e92df9a00 | |||
| 2df95b048f | |||
| bd94f12bb6 | |||
| 827b11092f | |||
| dcd986dc36 | |||
| 27dde9c826 | |||
| cc178efb9f | |||
| 8b27ddeb0a | |||
| 1274de63b5 | |||
| cc9853533f | |||
| 177c9a4bdc | |||
| 55cc55bcf2 |
@@ -1,24 +0,0 @@
|
|||||||
workflow "Send Notification" {
|
|
||||||
on = "push"
|
|
||||||
resolves = [
|
|
||||||
"Send Custom Message",
|
|
||||||
"Send Default Message"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Send Custom Message" {
|
|
||||||
uses = "appleboy/telegram-action@master"
|
|
||||||
secrets = [
|
|
||||||
"TELEGRAM_TOKEN",
|
|
||||||
"TELEGRAM_TO",
|
|
||||||
]
|
|
||||||
args = "A new commit has been pushed."
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Send Default Message" {
|
|
||||||
uses = "appleboy/telegram-action@master"
|
|
||||||
secrets = [
|
|
||||||
"TELEGRAM_TOKEN",
|
|
||||||
"TELEGRAM_TO",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
name: telegram message
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: send custom message with args
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
args: The ${{ github.event_name }} event triggered first step.
|
||||||
|
|
||||||
|
- name: send message using with
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: |
|
||||||
|
The ${{ github.event_name }} event triggered second step.
|
||||||
|
show the github variable ref: ${{ github.ref }}
|
||||||
|
show the github variable commit: ${{ github.sha }}
|
||||||
|
show the github variable ref: {{ commit.ref }}
|
||||||
|
show the github variable commit: {{ commit.sha }}
|
||||||
|
Commit Message: ${{ github.event.head_commit.message }}
|
||||||
|
|
||||||
|
- name: send default message
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
|
||||||
|
- name: send photo message
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: send photo message
|
||||||
|
photo: "./tests/github.png"
|
||||||
|
document: "./tests/gophercolor.png"
|
||||||
|
|
||||||
|
- name: send location message
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
location: "24.9163213 121.1424972"
|
||||||
|
venue: "35.661777 139.704051 竹北體育館 新竹縣竹北市"
|
||||||
|
|
||||||
|
- name: send custom message
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: |
|
||||||
|
The ${{ github.event_name }} event triggered final step.
|
||||||
|
echo This event is a pull request that had an assignee removed.
|
||||||
|
|
||||||
|
- name: send message file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message_file: tests/message.txt
|
||||||
|
|
||||||
|
# - name: send message using socks5 proxy URL
|
||||||
|
# uses: appleboy/telegram-action@master
|
||||||
|
# with:
|
||||||
|
# to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
# token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
# socks5: "http://222.124.154.19:23500"
|
||||||
|
# message: Send message from socks5 proxy URL.
|
||||||
|
|
||||||
|
# - name: try multiple message
|
||||||
|
# uses: appleboy/telegram-action@master
|
||||||
|
# with:
|
||||||
|
# to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
# token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
# format: html
|
||||||
|
# message: |
|
||||||
|
# ⚡️ <a href="https://github.com/aszenz/repo/commit/${{ github.event.push.after }}">Commits</a> pushed to master by <em>${{ github.event.push.pusher.name }}</em> ⚡️
|
||||||
|
# ${{ github.actor }}:${{ github.event.head_commit.message }}
|
||||||
|
|
||||||
|
- name: link preview
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: |
|
||||||
|
show link preview https://google.com.tw
|
||||||
|
|
||||||
|
- name: disable link preview
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
disable_web_page_preview: true
|
||||||
|
message: |
|
||||||
|
disable link preview https://google.com.tw
|
||||||
|
|
||||||
|
- name: sending a message without notification
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
disable_notification: true
|
||||||
|
message: |
|
||||||
|
disable link preview https://google.com.tw
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Goreleaser
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "^1"
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
# either 'goreleaser' (default) or 'goreleaser-pro'
|
||||||
|
distribution: goreleaser
|
||||||
|
version: latest
|
||||||
|
args: release --clean
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
builds:
|
||||||
|
- # If true, skip the build.
|
||||||
|
# Useful for library projects.
|
||||||
|
# Default is false
|
||||||
|
skip: true
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
use: github
|
||||||
|
groups:
|
||||||
|
- title: Features
|
||||||
|
regexp: "^.*feat[(\\w)]*:+.*$"
|
||||||
|
order: 0
|
||||||
|
- title: "Bug fixes"
|
||||||
|
regexp: "^.*fix[(\\w)]*:+.*$"
|
||||||
|
order: 1
|
||||||
|
- title: "Enhancements"
|
||||||
|
regexp: "^.*chore[(\\w)]*:+.*$"
|
||||||
|
order: 2
|
||||||
|
- title: "Refactor"
|
||||||
|
regexp: "^.*refactor[(\\w)]*:+.*$"
|
||||||
|
order: 3
|
||||||
|
- title: "Build process updates"
|
||||||
|
regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
|
||||||
|
order: 4
|
||||||
|
- title: "Documentation updates"
|
||||||
|
regexp: ^.*?docs?(\(.+\))??!?:.+$
|
||||||
|
order: 4
|
||||||
|
- title: Others
|
||||||
+5
-13
@@ -1,16 +1,8 @@
|
|||||||
FROM appleboy/drone-telegram:1.4.1-linux-amd64
|
FROM ghcr.io/appleboy/drone-telegram:1.4.0
|
||||||
|
|
||||||
# Github labels
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
LABEL "com.github.actions.name"="Telegram Notify"
|
|
||||||
LABEL "com.github.actions.description"="Sending a Telegram message"
|
|
||||||
LABEL "com.github.actions.icon"="message-square"
|
|
||||||
LABEL "com.github.actions.color"="blue"
|
|
||||||
|
|
||||||
LABEL "repository"="https://github.com/appleboy/telegram-action"
|
|
||||||
LABEL "homepage"="https://github.com/appleboy"
|
|
||||||
LABEL "maintainer"="Bo-Yi Wu <appleboy.tw@gmail.com>"
|
|
||||||
LABEL "version"="0.0.2"
|
|
||||||
|
|
||||||
ADD entrypoint.sh /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /github/workspace
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
@@ -1,49 +1,121 @@
|
|||||||
# 🚀 Telegram for GitHub Actions
|
# 🚀 Telegram for GitHub Actions
|
||||||
|
|
||||||
[GitHub Action](https://developer.github.com/actions/) for sending a Telegram notification message.
|
[GitHub Action](https://github.com/features/actions) for sending a Telegram notification message.
|
||||||
|
|
||||||
<img src="./images/telegram-notification.png">
|

|
||||||
|
|
||||||
|
[](https://github.com/appleboy/telegram-action/actions)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Send custom message as blow
|
**NOTE**: If you are getting "Error: Chat not found", then you need to look at this stackoverflow's answer [here](https://stackoverflow.com/a/41291666).
|
||||||
|
|
||||||
```
|
Send custom message and see the custom variable as below.
|
||||||
action "Send Custom Message" {
|
|
||||||
uses = "appleboy/telegram-action@master"
|
```yml
|
||||||
secrets = [
|
name: telegram message
|
||||||
"TELEGRAM_TOKEN",
|
on: [push]
|
||||||
"TELEGRAM_TO",
|
jobs:
|
||||||
]
|
|
||||||
args = "A new commit has been pushed."
|
build:
|
||||||
}
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: send telegram message on push
|
||||||
|
uses: appleboy/telegram-action@master
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: |
|
||||||
|
${{ github.actor }} created commit:
|
||||||
|
Commit message: ${{ github.event.commits[0].message }}
|
||||||
|
|
||||||
|
Repository: ${{ github.repository }}
|
||||||
|
|
||||||
|
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Send the default message. Please remove args
|
Remove `args` to send the default message.
|
||||||
|
|
||||||
```
|
```yml
|
||||||
action "Send Default Message" {
|
- name: send default message
|
||||||
uses = "appleboy/telegram-action@master"
|
uses: appleboy/telegram-action@master
|
||||||
secrets = [
|
with:
|
||||||
"TELEGRAM_TOKEN",
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
"TELEGRAM_TO",
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<img src="images/telegram-workflow.png">
|

|
||||||
|
|
||||||
|
## Input variables
|
||||||
|
|
||||||
|
* socks5 - optional. support socks5 proxy URL
|
||||||
|
* photo - optional. photo message
|
||||||
|
* document - optional. document message
|
||||||
|
* sticker - optional. sticker message
|
||||||
|
* audio - optional. audio message
|
||||||
|
* voice - optional. voice message
|
||||||
|
* location - optional. location message
|
||||||
|
* venue - optional. venue message
|
||||||
|
* video - optional. video message
|
||||||
|
* debug - optional. enable debug mode
|
||||||
|
* format - optional. `markdown` or `html`. See [MarkdownV2 style](https://core.telegram.org/bots/api#markdownv2-style)
|
||||||
|
* message - optional. custom message
|
||||||
|
* message_file - optional. overwrite the default message template with the contents of the specified file.
|
||||||
|
* disable_web_page_preview - optional. disables link previews for links in this message. default is `false`.
|
||||||
|
* disable_notification - optional. disables notifications for this message, supports sending a message without notification. default is `false`.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
send photo message:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: send photo message
|
||||||
|
uses: appleboy/telegram-action@master
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
message: send photo message
|
||||||
|
photo: tests/github.png
|
||||||
|
document: tests/gophercolor.png
|
||||||
|
```
|
||||||
|
|
||||||
|
send location message:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: send location message
|
||||||
|
uses: appleboy/telegram-action@master
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
location: '24.9163213 121.1424972'
|
||||||
|
venue: '35.661777 139.704051 竹北體育館 新竹縣竹北市'
|
||||||
|
```
|
||||||
|
|
||||||
|
send message using custom proxy (support `http`, `https`, and `socks5`) like `socks5://127.0.0.1:1080` or `http://222.124.154.19:23500`
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: send message using socks5 proxy URL
|
||||||
|
uses: appleboy/telegram-action@master
|
||||||
|
with:
|
||||||
|
to: ${{ secrets.TELEGRAM_TO }}
|
||||||
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
socks5: "http://222.124.154.19:23500"
|
||||||
|
message: Send message from socks5 proxy URL.
|
||||||
|
```
|
||||||
|
|
||||||
## Secrets
|
## Secrets
|
||||||
|
|
||||||
Getting started with [Telegram Bot API](https://core.telegram.org/bots/api).
|
Getting started with [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
* `TELEGRAM_TOKEN`: Telegram authorization token.
|
* `token`: Telegram authorization token.
|
||||||
* `TELEGRAM_TO`: Unique identifier for this chat.
|
* `to`: Unique identifier for this chat.
|
||||||
|
|
||||||
How to get unique identifier from telegram api:
|
How to get unique identifier from telegram api:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ curl https://api.telegram.org/bot<token>/getUpdates
|
curl https://api.telegram.org/bot<token>/getUpdates
|
||||||
```
|
```
|
||||||
|
|
||||||
See the result: (get chat id like `65382999`)
|
See the result: (get chat id like `65382999`)
|
||||||
@@ -78,3 +150,17 @@ See the result: (get chat id like `65382999`)
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Template variable
|
||||||
|
|
||||||
|
| Github Variable | Telegram Template Variable |
|
||||||
|
|-------------------|----------------------------|
|
||||||
|
| GITHUB_REPOSITORY | repo |
|
||||||
|
| GITHUB_ACTOR | repo.namespace |
|
||||||
|
| GITHUB_SHA | commit.sha |
|
||||||
|
| GITHUB_REF | commit.ref |
|
||||||
|
| GITHUB_WORKFLOW | github.workflow |
|
||||||
|
| GITHUB_ACTION | github.action |
|
||||||
|
| GITHUB_EVENT_NAME | github.event.name |
|
||||||
|
| GITHUB_EVENT_PATH | github.event.path |
|
||||||
|
| GITHUB_WORKSPACE | github.workspace |
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
name: 'Telegram Message Notify'
|
||||||
|
description: 'Sending a Telegram message'
|
||||||
|
author: 'Bo-Yi Wu'
|
||||||
|
inputs:
|
||||||
|
to:
|
||||||
|
description: 'telegram user'
|
||||||
|
token:
|
||||||
|
description: 'telegram token'
|
||||||
|
message:
|
||||||
|
description: 'telegram message'
|
||||||
|
message_file:
|
||||||
|
description: 'overwrite the default message template with the contents of the specified file'
|
||||||
|
socks5:
|
||||||
|
description: 'support socks5 proxy URL'
|
||||||
|
photo:
|
||||||
|
description: 'send the photo message.'
|
||||||
|
document:
|
||||||
|
description: 'send the document message.'
|
||||||
|
sticker:
|
||||||
|
description: 'send the sticker message.'
|
||||||
|
audio:
|
||||||
|
description: 'send the audio message.'
|
||||||
|
voice:
|
||||||
|
description: 'send the voice message.'
|
||||||
|
location:
|
||||||
|
description: 'send the location message.'
|
||||||
|
venue:
|
||||||
|
description: 'send the venue message.'
|
||||||
|
video:
|
||||||
|
description: 'send the video message.'
|
||||||
|
debug:
|
||||||
|
description: 'enable debug mode.'
|
||||||
|
format:
|
||||||
|
description: 'message format: markdown or html'
|
||||||
|
disable_web_page_preview:
|
||||||
|
description: 'disables link previews for links in this message'
|
||||||
|
disable_notification:
|
||||||
|
description: 'disables notifications for this message, supports sending a message without notification,'
|
||||||
|
runs:
|
||||||
|
using: 'docker'
|
||||||
|
image: 'Dockerfile'
|
||||||
|
|
||||||
|
branding:
|
||||||
|
icon: 'message-square'
|
||||||
|
color: 'blue'
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
Sample message loaded from file.
|
||||||
|
|
||||||
|
Commit msg: {{commit.message}}
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user