Skip to content

Instantly share code, notes, and snippets.

@QuvonchbekBobojonov
Last active December 16, 2023 10:17
Show Gist options
  • Save QuvonchbekBobojonov/845a86efe2434ce957ce76b91bd5ba8f to your computer and use it in GitHub Desktop.
Save QuvonchbekBobojonov/845a86efe2434ce957ce76b91bd5ba8f to your computer and use it in GitHub Desktop.
Action that sends a commit telegram chat to a project on github | Telegram Notification
name: Telegram Notification
on:
push:
branches:
- main
jobs:
send-telegram-notification:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install Dependencies
run: |
cd .github/workflows
npm install node-telegram-bot-api
npm install
- name: Send Telegram Notification
run: node ./.github/workflows/send-telegram-websocket.js
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN, { polling: false });
const commitMessage = process.env.GITHUB_EVENT_PATH ? require(process.env.GITHUB_EVENT_PATH).head_commit.message : '';
const repoName = process.env.GITHUB_REPOSITORY.split("/")[1];
const message = `${commitMessage} \n\n pushed to ${repoName} repository! \n\n@Sirojoff`;
bot.sendMessage(process.env.TELEGRAM_CHAT_ID, message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment