发布并推送到Telegram #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 发布并推送到Telegram | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| notify: | |
| name: 发布信息推送到Telegram | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 转换 Markdown 为 HTML | |
| id: convert | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const markdown = context.payload.release.body | |
| const html = await github.rest.markdown.render({ | |
| text: markdown, | |
| mode: 'gfm' | |
| }) | |
| // 处理 HTML 内容,移除不支持的标签和属性 | |
| const processedHtml = html.data | |
| .replace(/<p>/g, '') | |
| .replace(/<\/p>/g, '\n') | |
| .replace(/<br>/g, '\n') | |
| .replace(/<a class="[^"]*" href="([^"]*)">([^<]*)<\/a>/g, '<a href="$1">$2</a>') | |
| .replace(/<tt>([^<]*)<\/tt>/g, '$1') | |
| .replace(/<strong>([^<]*)<\/strong>/g, '<b>$1</b>') | |
| .replace(/"/g, '') // 移除所有引号 | |
| .replace(/\n{3,}/g, '\n\n') // 将多个换行符替换为两个 | |
| .trim() // 移除首尾空白 | |
| return processedHtml | |
| - name: 发送Telegram通知 | |
| uses: appleboy/telegram-action@master | |
| with: | |
| to: ${{ secrets.TELEGRAM_CHAT_ID }} | |
| token: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| format: html | |
| message: | | |
| <b>版本: ${{ github.event.release.tag_name }}</b> | |
| <b>更新内容:</b> | |
| ${{ steps.convert.outputs.result }} | |
| <b>压缩包下载:</b> | |
| <a href="${{ github.event.release.html_url }}">点击下载</a> | |
| <b>Docker:</b> | |
| <a href="https://github.com/setube/stb/pkgs/container/stb">点击查看</a> |