This commit is contained in:
Kirill Chikalin
2025-03-20 08:45:16 +03:00
parent f5396fe27e
commit 02fce37a63
2 changed files with 11 additions and 36 deletions

View File

@@ -25,35 +25,21 @@ inputs:
description: "Message ID" description: "Message ID"
required: false required: false
default: ${{ secrets.TELEGRAM_TOKEN }} default: ${{ secrets.TELEGRAM_TOKEN }}
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs: outputs:
message_id: message_id:
description: "Message ID" description: "Message ID"
value: ${{ env.TELEGRAM_MESSAGE_ID }} value: ${{ env.OUTPUT_MESSAGE_ID }}
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-number }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Set Greeting - name: Setup
run: | run: echo "OUTPUT_MESSAGE_ID=" >> $GITHUB_ENV
echo "Hello $INPUT_WHO_TO_GREET."
echo MESSAGE=$MESSAGE
echo inputs.message_id==${{ inputs.message_id }}
echo env.MESSAGE_ID=${{ env.MESSAGE_ID }}
shell: bash shell: bash
env:
INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}
MESSAGE: ${{ inputs.message_id }}
- name: Random Number Generator # - name: Random Number Generator
id: random-number-generator # id: random-number-generator
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT # run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: bash # shell: bash
- name: Set GitHub Path - name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
@@ -62,9 +48,5 @@ runs:
GITHUB_ACTION_PATH: ${{ github.action_path }} GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: Send message - name: Send message
run: sendMessage ${{ inputs.bot_token }} ${{ inputs.chat_id }} ${{ inputs.message }} run: sendMessage "${{ inputs.bot_token }}" "${{ inputs.chat_id }}" "${{ inputs.message }}"
shell: bash
- name: Run goodbye.sh
run: goodbye.sh
shell: bash shell: bash

View File

@@ -1,16 +1,10 @@
#!/bin/bash #!/bin/bash
MESSAGE=$(echo -e "$3") response=$(curl -s -X POST "https://api.telegram.org/bot$1/sendMessage" \
token=$1
echo chat_id=$2
echo text=$MESSAGE
response=$(curl -s -X POST "https://api.telegram.org/bot$token/sendMessage" \
-d "chat_id=$2" \ -d "chat_id=$2" \
-d "parse_mode=MarkdownV2" \ -d "parse_mode=MarkdownV2" \
-d "link_preview_options={\"is_disabled\":true}" \ -d "link_preview_options={\"is_disabled\":true}" \
-d "text=test: $MESSAGE") -d "text=test: $3")
# if command -v jq >/dev/null 2>&1; then # if command -v jq >/dev/null 2>&1; then
message_id=$(echo "$response" | jq '.result.message_id') message_id=$(echo "$response" | jq '.result.message_id')
@@ -18,5 +12,4 @@ response=$(curl -s -X POST "https://api.telegram.org/bot$token/sendMessage" \
# message_id=$(echo "$response" | grep -o '"message_id":[0-9]*' | sed 's/"message_id"://') # message_id=$(echo "$response" | grep -o '"message_id":[0-9]*' | sed 's/"message_id"://')
# fi # fi
echo "Sent message ID: $message_id" echo "OUTPUT_MESSAGE_ID=$message_id" >> $GITHUB_ENV
echo "TELEGRAM_MESSAGE_ID=$message_id" >> $GITHUB_ENV