mirror of
https://github.com/appleboy/telegram-action.git
synced 2026-05-14 10:52:51 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae54341a85 | |||
| 70b64f5beb | |||
| 7347add3d3 | |||
| 6c7afcc8db | |||
| 372c737013 | |||
| 1b52d8d894 |
@@ -0,0 +1,38 @@
|
|||||||
|
workflow "Send Notification" {
|
||||||
|
on = "push"
|
||||||
|
resolves = [
|
||||||
|
"Send Custom Message",
|
||||||
|
"Send Default Message",
|
||||||
|
"Send Photo 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",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "Send Photo Message" {
|
||||||
|
uses = "appleboy/telegram-action@master"
|
||||||
|
env = {
|
||||||
|
PHOTO = "tests/github.png"
|
||||||
|
DOCUMENT = "tests/gophercolor.png"
|
||||||
|
}
|
||||||
|
secrets = [
|
||||||
|
"TELEGRAM_TOKEN",
|
||||||
|
"TELEGRAM_TO",
|
||||||
|
]
|
||||||
|
args = "send photo message."
|
||||||
|
}
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
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: appleboy/telegram-action@master
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
args: The ${{ github.event_name }} event triggered first step.
|
|
||||||
|
|
||||||
- name: send message useing with
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
message: The ${{ github.event_name }} event triggered second step.
|
|
||||||
|
|
||||||
- name: send default message
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
|
|
||||||
- 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'
|
|
||||||
|
|
||||||
- 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 竹北體育館 新竹縣竹北市'
|
|
||||||
|
|
||||||
- name: send custom message
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
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: appleboy/telegram-action@master
|
|
||||||
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.
|
|
||||||
+12
-4
@@ -1,8 +1,16 @@
|
|||||||
FROM appleboy/drone-telegram:1.3.5-linux-amd64
|
FROM appleboy/drone-telegram:1.4.2-linux-amd64
|
||||||
|
|
||||||
|
# Github labels
|
||||||
|
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
|
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,124 +1,77 @@
|
|||||||
# 🚀 Telegram for GitHub Actions
|
# 🚀 Telegram for GitHub Actions
|
||||||
|
|
||||||
[GitHub Action](https://github.com/features/actions) for sending a Telegram notification message.
|
[GitHub Action](https://developer.github.com/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 and see the custom variable as blow.
|
Send custom message as blow
|
||||||
|
|
||||||
```yml
|
```
|
||||||
name: telegram message
|
action "Send Custom Message" {
|
||||||
on: [push]
|
uses = "appleboy/telegram-action@master"
|
||||||
jobs:
|
secrets = [
|
||||||
|
"TELEGRAM_TOKEN",
|
||||||
build:
|
"TELEGRAM_TO",
|
||||||
name: Build
|
]
|
||||||
runs-on: ubuntu-latest
|
args = "A new commit has been pushed."
|
||||||
steps:
|
}
|
||||||
- uses: actions/checkout@master
|
|
||||||
- name: send custom message with args
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
args: The ${{ github.event_name }} event triggered first step.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Remove `args` to send the default message.
|
Remove `args` to send the default message.
|
||||||
|
|
||||||
```yml
|
```
|
||||||
- name: send default message
|
action "Send Default Message" {
|
||||||
uses: appleboy/telegram-action@master
|
uses = "appleboy/telegram-action@master"
|
||||||
with:
|
secrets = [
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
"TELEGRAM_TOKEN",
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
"TELEGRAM_TO",
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||

|
<img src="images/telegram-workflow.png">
|
||||||
|
|
||||||
## Input variables
|
## Environment variables
|
||||||
|
|
||||||
* socks5 - optional. support socks5 proxy URL
|
* PHOTO - Optional. photo message
|
||||||
* photo - optional. photo message
|
* DOCUMENT - Optional. document message
|
||||||
* document - optional. document message
|
* STICKER - Optional. sticker message
|
||||||
* sticker - optional. sticker message
|
* AUDIO - Optional. audio message
|
||||||
* audio - optional. audio message
|
* VOICE - Optional. voice message
|
||||||
* voice - optional. voice message
|
* LOCATION - Optional. location message
|
||||||
* location - optional. location message
|
* VENUE - Optional. venue message
|
||||||
* venue - optional. venue message
|
* VIDEO - Optional. video message
|
||||||
* video - optional. video message
|
* DEBUG - Optional. enable debug mode
|
||||||
* debug - optional. enable debug mode
|
|
||||||
* format - optional. `markdown` or `html`
|
|
||||||
* message_file - optional. overwrite the default message template with the contents of the specified file.
|
|
||||||
|
|
||||||
## Example
|
### 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
|
|
||||||
```
|
```
|
||||||
|
action "Send photo message" {
|
||||||
send location message:
|
uses = "appleboy/telegram-action@master"
|
||||||
|
secrets = [
|
||||||
```yml
|
"TELEGRAM_TOKEN",
|
||||||
- name: send location message
|
"TELEGRAM_TO",
|
||||||
uses: appleboy/telegram-action@master
|
]
|
||||||
with:
|
env = {
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
PHOTO = "tests/github.png"
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
}
|
||||||
location: '24.9163213 121.1424972'
|
args = "A new commit has been pushed."
|
||||||
venue: '35.661777 139.704051 竹北體育館 新竹縣竹北市'
|
}
|
||||||
```
|
|
||||||
|
|
||||||
send custom message:
|
|
||||||
|
|
||||||
```yml
|
|
||||||
- name: send custom message
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
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.
|
|
||||||
```
|
|
||||||
|
|
||||||
send message using custom proxy (support `http`, `https`, and `socks5`)
|
|
||||||
|
|
||||||
```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).
|
||||||
|
|
||||||
* `token`: Telegram authorization token.
|
* `TELEGRAM_TOKEN`: Telegram authorization token.
|
||||||
* `to`: Unique identifier for this chat.
|
* `TELEGRAM_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`)
|
||||||
@@ -153,17 +106,3 @@ 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 |
|
|
||||||
|
|||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
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'
|
|
||||||
runs:
|
|
||||||
using: 'docker'
|
|
||||||
image: 'Dockerfile'
|
|
||||||
|
|
||||||
branding:
|
|
||||||
icon: 'message-square'
|
|
||||||
color: 'blue'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Sample message loaded from file.
|
|
||||||
|
|
||||||
Commit msg: {{commit.message}}
|
|
||||||
Reference in New Issue
Block a user