Compare commits

..

59 Commits

Author SHA1 Message Date
Kirill Chikalin
5ea0967216 fix 2025-06-02 08:32:13 +03:00
Kirill Chikalin
3c121c1f2e test with variable 2025-06-02 08:27:43 +03:00
Kirill Chikalin
e7a5755848 remove \n 2025-06-02 08:00:34 +03:00
Kirill Chikalin
535dca65f1 fix text to send 2025-06-02 07:49:02 +03:00
Kirill Chikalin
7601520082 use echo -e 2025-06-02 07:41:42 +03:00
Kirill Chikalin
d2366e36cd use echo -e 2025-06-02 07:35:28 +03:00
Kirill Chikalin
190eefee83 add logs, parse before script 2025-06-02 07:14:36 +03:00
Kirill Chikalin
5033c1b568 remove \n 2025-06-02 07:07:23 +03:00
Kirill Chikalin
9a927d171b send button only on success 2025-06-02 07:05:22 +03:00
Kirill Chikalin
c1ed7f0629 use # symbol 2025-06-01 19:00:34 +03:00
Kirill Chikalin
3eb184ef8d revert text parsing 2025-06-01 18:57:44 +03:00
Kirill Chikalin
e8978753e0 add inline keyboard button 2025-06-01 18:55:20 +03:00
Kirill Chikalin
73032ddbf6 close </a> 2025-03-21 16:45:59 +03:00
Kirill Chikalin
8bdd382865 add runners list url 2025-03-21 16:37:02 +03:00
Kirill Chikalin
dce8f35afd test env GITEA_RUNNER_NAME 2025-03-21 16:16:01 +03:00
Kirill Chikalin
8bf063c745 update default caption 2025-03-20 12:23:32 +03:00
Kirill Chikalin
6e8875ec64 default message 2025-03-20 12:18:52 +03:00
Kirill Chikalin
ce44b8103e <code> 2025-03-20 10:29:44 +03:00
Kirill Chikalin
4caca226eb test \n 2025-03-20 10:27:25 +03:00
Kirill Chikalin
95d1d196a6 remove br 2025-03-20 10:25:56 +03:00
Kirill Chikalin
242315b7dc echo 2025-03-20 10:24:41 +03:00
Kirill Chikalin
86b469f293 fix 2025-03-20 10:22:19 +03:00
Kirill Chikalin
616ece8334 fix 2025-03-20 10:21:06 +03:00
Kirill Chikalin
eccc9fcc11 fix status 2025-03-20 10:18:48 +03:00
Kirill Chikalin
0c86f5d6e9 default status 2025-03-20 10:11:04 +03:00
Kirill Chikalin
0f68e5820b status 2025-03-20 10:10:10 +03:00
Kirill Chikalin
da881f4c66 fix if 2025-03-20 10:03:21 +03:00
Kirill Chikalin
55bfb03959 fix 2025-03-20 10:01:16 +03:00
Kirill Chikalin
0e0d598b6d prefix message, default message 2025-03-20 09:59:05 +03:00
Kirill Chikalin
1050b3ca34 curl -s --show-error 2025-03-20 09:39:58 +03:00
Kirill Chikalin
911c967f33 fix echo 2025-03-20 09:35:31 +03:00
Kirill Chikalin
692594260e status input 2025-03-20 09:33:36 +03:00
Kirill Chikalin
52c5d43868 job status step 2025-03-20 09:26:57 +03:00
Kirill Chikalin
a08e08aa3f fix 2025-03-20 09:23:28 +03:00
Kirill Chikalin
6b383bd323 fix 2025-03-20 09:21:28 +03:00
Kirill Chikalin
fd9a507b3b test delete if 2025-03-20 09:21:14 +03:00
Kirill Chikalin
288b061064 test 2025-03-20 09:20:15 +03:00
Kirill Chikalin
760f4127ee test 2025-03-20 09:19:28 +03:00
Kirill Chikalin
90adf30064 test if 2025-03-20 09:18:31 +03:00
Kirill Chikalin
1748c3fbad fix parse_mode 2025-03-20 09:14:10 +03:00
Kirill Chikalin
7e40bc125a test 2025-03-20 09:13:08 +03:00
Kirill Chikalin
1986895b2e test 2025-03-20 09:12:26 +03:00
Kirill Chikalin
8eb3c74cd2 fix 2025-03-20 09:08:54 +03:00
Kirill Chikalin
04067a758a test 2025-03-20 09:04:11 +03:00
Kirill Chikalin
6aa7b222ce test 2025-03-20 09:03:31 +03:00
Kirill Chikalin
bd971edf91 test 2025-03-20 09:02:48 +03:00
Kirill Chikalin
9c28cb7a93 test 2025-03-20 09:01:47 +03:00
Kirill Chikalin
9a1eb86093 try 2025-03-20 09:00:44 +03:00
Kirill Chikalin
959fd6e8d9 test 2025-03-20 08:58:35 +03:00
Kirill Chikalin
986af9d158 fix 2025-03-20 08:57:38 +03:00
Kirill Chikalin
472094ff25 test 2025-03-20 08:56:14 +03:00
Kirill Chikalin
4bc71a8287 echo 2025-03-20 08:55:25 +03:00
Kirill Chikalin
6c06b3e4bd echo message 2025-03-20 08:54:49 +03:00
Kirill Chikalin
02fce37a63 fix 2025-03-20 08:45:16 +03:00
Kirill Chikalin
f5396fe27e test 2025-03-20 08:35:52 +03:00
Kirill Chikalin
d6d3cd31ba test 2025-03-20 08:32:26 +03:00
Kirill Chikalin
a5f446cc39 fix? 2025-03-20 08:30:46 +03:00
Kirill Chikalin
db88d660cf text to message 2025-03-20 08:27:28 +03:00
Kirill Chikalin
d185edb3fc curl -v 2025-03-20 08:26:07 +03:00
4 changed files with 120 additions and 51 deletions

View File

@@ -1,22 +1,40 @@
name: 'Hello World'
description: 'Greet someone'
name: 'Telegram Bot'
description: 'Telegram Bot API'
inputs:
text:
message:
description: "Text"
required: false
default: ""
default: ''
caption:
description: "Text"
required: false
default: |
<a href='${{ github.event.repository.html_url }}/actions/runs/${{ github.run_number }}'>#${{ github.run_number }}</a> <b>${{ github.event.repository.name }}</b>: ${{ github.workflow }}
on: <a href='${{ github.server_url }}/-/admin/actions/runners'>${{ env.GITEA_RUNNER_NAME }}</a>
button_url:
description: "Button URL"
required: false
default: ''
button_title:
description: "Button title"
required: false
default: ''
message_id:
description: "Message ID"
required: false
default: ""
default: ''
# update:
# description: "Update message by ID"
# required: false
# default: 'false'
# delete:
# description: "Update message by ID"
# required: false
# default: 'false'
delete:
description: "Message ID to delete"
required: false
default: ''
status:
description: "Status message"
required: false
default: ${{ job.status }}
chat_id:
description: "Chat ID"
required: true
@@ -25,35 +43,21 @@ inputs:
description: "Message ID"
required: false
default: ${{ secrets.TELEGRAM_TOKEN }}
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
message_id:
description: "Message ID"
value: ${{ env.TELEGRAM_MESSAGE_ID }}
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-number }}
value: ${{ env.OUTPUT_MESSAGE_ID }}
runs:
using: "composite"
steps:
- name: Set Greeting
run: |
echo "Hello $INPUT_WHO_TO_GREET."
echo MESSAGE=$MESSAGE
echo inputs.message_id==${{ inputs.message_id }}
echo env.MESSAGE_ID=${{ env.MESSAGE_ID }}
- name: Setup
run: echo "OUTPUT_MESSAGE_ID=" >> $GITHUB_ENV
shell: bash
env:
INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}
MESSAGE: ${{ inputs.message_id }}
- name: Random Number Generator
id: random-number-generator
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: bash
# - name: Random Number Generator
# id: random-number-generator
# run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
# shell: bash
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
@@ -62,9 +66,45 @@ runs:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: Send message
run: sendMessage ${{ inputs.bot_token }} ${{ inputs.chat_id }} ${{ inputs.text }}
run: |
button_url=${{ inputs.button_url }}
STATUS=${{ inputs.status }}
if [[ "$STATUS" == "success" ]]; then
STATUS="✅"
elif [[ "$STATUS" == "failure" ]]; then
STATUS="❌"
button_url=""
elif [[ "$STATUS" == "cancelled" ]]; then
STATUS="⚠️"
button_url=""
fi
if [[ "$STATUS" != '' ]]; then
STATUS="$STATUS "
fi
CAPTION="$STATUS${{ inputs.caption }}"
echo "Caption: $CAPTION"
message="${{ inputs.message }}"
PARSED_TEXT=$(echo -e "$CAPTION$message")
echo "PARSED_TEXT: $PARSED_TEXT"
sendMessage "${{ inputs.bot_token }}" ${{ inputs.chat_id }} "$PARSED_TEXT" "${{ inputs.button_title }}" "$button_url"
shell: bash
- name: Run goodbye.sh
run: goodbye.sh
shell: bash
- name: Delete message
if: inputs.delete != ''
run: deleteMessage "${{ inputs.bot_token }}" ${{ inputs.chat_id }} ${{ inputs.delete }}
shell: bash
# - name: Send job status
# if: inputs.status != ''
# run: |
# if [[ "${{ job.status }}" == "success" ]]; then
# STATUS="✅"
# elif [[ "${{ job.status }}" == "failure" ]]; then
# STATUS="❌"
# elif [[ "${{ job.status }}" == "cancelled" ]]; then
# STATUS="⚠️"
# else
# STATUS="❓"
# fi
# sendMessage "${{ inputs.bot_token }}" ${{ inputs.chat_id }} "$STATUS ${{ inputs.status }}"
# shell: bash

7
deleteMessage Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
curl -s --show-error -X POST "https://api.telegram.org/bot$1/deleteMessage" \
-d "message_id=$3" \
-d "chat_id=$2"
echo "Message with ID $3 was deleted"

View File

@@ -1 +0,0 @@
echo Goodbye

View File

@@ -1,22 +1,45 @@
#!/bin/bash
MESSAGE=$(echo -e "$3")
BOT_TOKEN="$1"
CHAT_ID="$2"
TEXT="$3"
DOWNLOAD_TITLE="$4" # Необязательный
DOWNLOAD_URL="$5" # Необязательный
echo token=$1
echo chat_id=$2
echo text=$3
# Базовый JSON без reply_markup
JSON=$(jq -nc \
--arg chat_id "$CHAT_ID" \
--arg text "$TEXT" \
'{
chat_id: $chat_id,
text: $text,
parse_mode: "HTML",
link_preview_options: { "is_disabled": true }
}')
response=$(curl -s -X POST "https://api.telegram.org/bot$1/sendMessage" \
-d "chat_id=$2" \
-d "parse_mode=MarkdownV2" \
-d "link_preview_options={\"is_disabled\":true}" \
-d "text=test: $(echo -e "$3")")
# Если передана ссылка — добавим кнопку
if [[ -n "$DOWNLOAD_URL" ]]; then
JSON=$(echo "$JSON" | jq \
--arg text "$DOWNLOAD_TITLE" \
--arg url "$DOWNLOAD_URL" \
'. + {
reply_markup: {
inline_keyboard: [[
{ text: $text, url: $url }
]]
}
}')
fi
# if command -v jq >/dev/null 2>&1; then
message_id=$(echo "$response" | jq '.result.message_id')
# else
# message_id=$(echo "$response" | grep -o '"message_id":[0-9]*' | sed 's/"message_id"://')
# fi
echo "$JSON: $JSON"
echo "Sent message ID: $message_id"
echo "TELEGRAM_MESSAGE_ID=$message_id" >> $GITHUB_ENV
# Отправка запроса
response=$(curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d "$JSON")
# Получаем message_id
message_id=$(echo "$response" | jq '.result.message_id')
echo "Sent message with ID: $message_id"
echo "OUTPUT_MESSAGE_ID=$message_id" >> "$GITHUB_ENV"