Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/telegram-notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ jobs:
if: ${{ github.event_name == 'issues' }}
run: |
ESCAPED_BODY=$(echo "${{ github.event.issue.body }}" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')
echo "ESCAPED_BODY=$ESCAPED_BODY" >> $GITHUB_ENV
echo "ESCAPED_BODY=$(echo "$ESCAPED_BODY" | tr -d '\r')" >> $GITHUB_ENV

# --- Escape Comment Body ---
- name: Escape Comment Body
if: ${{ github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' }}
run: |
ESCAPED_COMMENT=$(echo "${{ github.event.comment.body }}" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')
echo "ESCAPED_COMMENT=$ESCAPED_COMMENT" >> $GITHUB_ENV
echo "ESCAPED_COMMENT=$(echo "$ESCAPED_COMMENT" | tr -d '\r')" >> $GITHUB_ENV

# --- Escape PR Body ---
- name: Escape PR Body
if: ${{ github.event_name == 'pull_request' }}
run: |
ESCAPED_PR_BODY=$(echo "${{ github.event.pull_request.body }}" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')
echo "ESCAPED_PR_BODY=$ESCAPED_PR_BODY" >> $GITHUB_ENV
echo "ESCAPED_PR_BODY=$(echo "$ESCAPED_PR_BODY" | tr -d '\r')" >> $GITHUB_ENV

# --- Telegram: Issue ---
- name: Send Telegram (Issue)
Expand Down
209 changes: 209 additions & 0 deletions .github/workflows/telegram-notifications2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: Telegram Notifications v2

on:
issues:
types: [opened, edited, closed]
issue_comment:
types: [created]
pull_request:
types: [opened, edited, closed, reopened]
pull_request_review_comment:
types: [created]

jobs:
send_notification:
runs-on: ubuntu-latest
steps:
- name: Build Telegram message (Issue)
if: ${{ github.event_name == 'issues' }}
shell: bash
env:
BODY: ${{ github.event.issue.body }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ACTOR: ${{ github.actor }}
ACTION: ${{ github.event.action }}
TITLE: ${{ github.event.issue.title }}
run: |
ESCAPED_BODY=$(printf '%s' "$BODY" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ISSUE_URL=$(printf '%s' "$ISSUE_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTION=$(printf '%s' "$ACTION" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_TITLE=$(printf '%s' "$TITLE" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

cat > tg_message.html <<'EOF'
🚨 Issue Notification 🚨
EOF

{
echo "<b>Issue URL:</b> $ESCAPED_ISSUE_URL"
echo "<b>$ESCAPED_ACTOR</b> triggered issue event: <b>$ESCAPED_ACTION</b>"
echo "<b>Title:</b> $ESCAPED_TITLE"
echo "<blockquote>$ESCAPED_BODY</blockquote>"
} >> tg_message.html

- name: Send Telegram (Issue)
if: ${{ github.event_name == 'issues' }}
uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message_file: tg_message.html

- name: Build Telegram message (Issue Comment)
if: ${{ github.event_name == 'issue_comment' }}
shell: bash
env:
BODY: ${{ github.event.comment.body }}
COMMENT_URL: ${{ github.event.comment.html_url }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ACTOR: ${{ github.actor }}
run: |
ESCAPED_COMMENT=$(printf '%s' "$BODY" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_COMMENT_URL=$(printf '%s' "$COMMENT_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ISSUE_URL=$(printf '%s' "$ISSUE_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

cat > tg_message.html <<'EOF'
📝 Comment on Issue 📝
EOF

{
echo "<b>Comment URL:</b> $ESCAPED_COMMENT_URL"
echo "<b>Issue URL:</b> $ESCAPED_ISSUE_URL"
echo "<b>$ESCAPED_ACTOR</b> commented:"
echo "<blockquote>$ESCAPED_COMMENT</blockquote>"
} >> tg_message.html

- name: Send Telegram (Issue Comment)
if: ${{ github.event_name == 'issue_comment' }}
uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message_file: tg_message.html

- name: Build Telegram message (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
shell: bash
env:
BODY: ${{ github.event.pull_request.body }}
PR_URL: ${{ github.event.pull_request.html_url }}
ACTOR: ${{ github.actor }}
ACTION: ${{ github.event.action }}
TITLE: ${{ github.event.pull_request.title }}
run: |
ESCAPED_PR_BODY=$(printf '%s' "$BODY" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_PR_URL=$(printf '%s' "$PR_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTION=$(printf '%s' "$ACTION" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_TITLE=$(printf '%s' "$TITLE" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

cat > tg_message.html <<'EOF'
🚀 Pull Request Notification 🚀
EOF

{
echo "<b>PR URL:</b> $ESCAPED_PR_URL"
echo "<b>$ESCAPED_ACTOR</b> triggered PR event: <b>$ESCAPED_ACTION</b>"
echo "<b>Title:</b> $ESCAPED_TITLE"
echo "<blockquote>$ESCAPED_PR_BODY</blockquote>"
} >> tg_message.html

- name: Send Telegram (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message_file: tg_message.html

- name: Build Telegram message (PR Comment)
if: ${{ github.event_name == 'pull_request_review_comment' }}
shell: bash
env:
BODY: ${{ github.event.comment.body }}
COMMENT_URL: ${{ github.event.comment.html_url }}
PR_URL: ${{ github.event.pull_request.html_url }}
ACTOR: ${{ github.actor }}
run: |
ESCAPED_COMMENT=$(printf '%s' "$BODY" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_COMMENT_URL=$(printf '%s' "$COMMENT_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_PR_URL=$(printf '%s' "$PR_URL" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \
| tr -d '\r' \
| sed -e 's/&/\&amp;amp;/g' -e 's/</\&amp;lt;/g' -e 's/>/\&amp;gt;/g')

cat > tg_message.html <<'EOF'
💬 Comment on Pull Request 💬
EOF

{
echo "<b>Comment URL:</b> $ESCAPED_COMMENT_URL"
echo "<b>PR URL:</b> $ESCAPED_PR_URL"
echo "<b>$ESCAPED_ACTOR</b> commented:"
echo "<blockquote>$ESCAPED_COMMENT</blockquote>"
} >> tg_message.html

- name: Send Telegram (PR Comment)
if: ${{ github.event_name == 'pull_request_review_comment' }}
uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message_file: tg_message.html