|
21 | 21 | GITHUB_REPOSITORY: ${{ github.repository }} |
22 | 22 | GITHUB_REF: ${{ github.ref }} |
23 | 23 | GITHUB_SHA: ${{ github.sha }} |
| 24 | + GITHUB_EVENT_PATH: ${{ github.event_path }} |
24 | 25 |
|
25 | 26 | jobs: |
26 | 27 | telegram-notify: |
|
40 | 41 | run: npm install node-fetch |
41 | 42 |
|
42 | 43 | - name: Send Telegram notification |
43 | | - run: | |
44 | | - node -e " |
45 | | - import fetch from 'node-fetch'; |
46 | | -
|
47 | | - const token = process.env.TELEGRAM_BOT_TOKEN; |
48 | | - const chatId = process.env.TELEGRAM_CHAT_ID; |
49 | | - const actor = process.env.GITHUB_ACTOR; |
50 | | - const event = process.env.GITHUB_EVENT_NAME; |
51 | | - const repo = process.env.GITHUB_REPOSITORY; |
52 | | - const ref = process.env.GITHUB_REF; |
53 | | - const sha = process.env.GITHUB_SHA; |
54 | | -
|
55 | | - let message = `*GitHub Notification*\nRepository: ${repo}\nActor: ${actor}\nEvent: ${event}\nRef: ${ref}\nSHA: ${sha}`; |
56 | | -
|
57 | | - if (event === 'pull_request') { |
58 | | - const pr = JSON.parse(process.env.GITHUB_EVENT_PATH); |
59 | | - message += `\nPR Title: ${pr.pull_request.title}\nAction: ${pr.action}\nURL: ${pr.pull_request.html_url}`; |
60 | | - } |
61 | | -
|
62 | | - if (event === 'issues') { |
63 | | - const issue = JSON.parse(process.env.GITHUB_EVENT_PATH); |
64 | | - message += `\nIssue Title: ${issue.issue.title}\nAction: ${issue.action}\nURL: ${issue.issue.html_url}`; |
65 | | - } |
66 | | -
|
67 | | - fetch(`https://api.telegram.org/bot${token}/sendMessage`, { |
68 | | - method: 'POST', |
69 | | - headers: { 'Content-Type': 'application/json' }, |
70 | | - body: JSON.stringify({ |
71 | | - chat_id: chatId, |
72 | | - text: message, |
73 | | - parse_mode: 'Markdown' |
74 | | - }) |
75 | | - }); |
76 | | - " |
| 44 | + run: node scripts/telegram-notify.js |
0 commit comments