Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrszacilowski authored Jul 18, 2024
2 parents 7319023 + 295cb40 commit e856ab6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
validate_and_notify:
runs-on: ubuntu-latest
name: Validate JSON and Notify on Telegram
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.BOTTOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.CHATID }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -92,16 +95,31 @@ jobs:
fi
echo "TG_SENDER_PAYLOAD_MESSAGE=$message" >> $GITHUB_ENV
- name: Verify Secret Access
run: |
if [ -n "${{ secrets.BOTTOKEN }}" ] && [ -n "${{ secrets.CHATID }}" ]; then
echo "Secrets appear to be set"
else
echo "One or both secrets are not set"
exit 1
fi
- name: Send Notification to Telegram
if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success()
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.BOTTOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.CHATID }}
run: |
curl -X POST \
response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Content-Type: application/json" \
-d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"${{ env.TG_SENDER_PAYLOAD_MESSAGE }}\"}" \
"https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage"
-d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"$TG_SENDER_PAYLOAD_MESSAGE\"}" \
"https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage")
if [ "$response" = "200" ]; then
echo "Message sent successfully"
else
echo "Failed to send message. HTTP status code: $response"
exit 1
fi
# if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success()
# run: |
Expand Down

0 comments on commit e856ab6

Please sign in to comment.