-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,26 @@ | ||
name: Notify Telegram | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
types: [opened, closed, reopened, synchronized] | ||
issues: | ||
types: [opened, closed, reopened] | ||
fork: | ||
watch: | ||
release: | ||
create: | ||
delete: | ||
discussion: | ||
workflow_run: | ||
|
||
jobs: | ||
notify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Send Telegram Notification for All Events | ||
env: | ||
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
run: | | ||
EVENT_NAME=${{ github.event_name }} | ||
REPO_NAME=${{ github.repository }} | ||
ACTOR=${{ github.actor }} | ||
REF=${{ github.ref_name }} | ||
ACTION=${{ github.event.action }} | ||
if [ "${EVENT_NAME}" == "push" ]; then | ||
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | ||
COMMIT_HASH=$(git log -1 --pretty=%h) | ||
COMMIT_URL=${{ github.event.head_commit.url }} | ||
MESSAGE="🔨 1 Commit baru ke *${REPO_NAME}[${REF}]*\n\n• \`${COMMIT_HASH}\` - ${COMMIT_MESSAGE} oleh *${ACTOR}*\n\n[Open Change](${COMMIT_URL})" | ||
elif [ "${EVENT_NAME}" == "pull_request" ]; then | ||
PR_TITLE=${{ github.event.pull_request.title }} | ||
PR_URL=${{ github.event.pull_request.html_url }} | ||
MESSAGE="🔄 Pull Request *${ACTION}* ke *${REPO_NAME}*\n\n• *${PR_TITLE}* oleh *${ACTOR}*\n\n[Open PR](${PR_URL})" | ||
elif [ "${EVENT_NAME}" == "issues" ]; then | ||
ISSUE_TITLE=${{ github.event.issue.title }} | ||
ISSUE_URL=${{ github.event.issue.html_url }} | ||
MESSAGE="🔔 Issue *${ACTION}* di *${REPO_NAME}*\n\n• *${ISSUE_TITLE}* oleh *${ACTOR}*\n\n[Open Issue](${ISSUE_URL})" | ||
elif [ "${EVENT_NAME}" == "fork" ]; then | ||
FORK_URL=${{ github.event.forkee.html_url }} | ||
MESSAGE="🍴 Repository *${REPO_NAME}* difork oleh *${ACTOR}*\n\n[Open Fork](${FORK_URL})" | ||
elif [ "${EVENT_NAME}" == "watch" ]; then | ||
MESSAGE="⭐ *${ACTOR}* memberi bintang pada *${REPO_NAME}*" | ||
elif [ "${EVENT_NAME}" == "release" ]; then | ||
RELEASE_TITLE=${{ github.event.release.name }} | ||
RELEASE_URL=${{ github.event.release.html_url }} | ||
MESSAGE="🚀 Rilis baru *${RELEASE_TITLE}* di *${REPO_NAME}* oleh *${ACTOR}*\n\n[Open Release](${RELEASE_URL})" | ||
else | ||
MESSAGE="📢 Event *${EVENT_NAME}* terjadi di *${REPO_NAME}* oleh *${ACTOR}*" | ||
fi | ||
curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \ | ||
-d chat_id=${{ env.CHAT_ID }} \ | ||
-d parse_mode="Markdown" \ | ||
-d text="${MESSAGE}" | ||
name: Notify on Telegram | ||
|
||
on: | ||
fork: | ||
push: | ||
release: | ||
issue_comment: | ||
types: created | ||
watch: | ||
types: started | ||
pull_request_review_comment: | ||
types: created | ||
pull_request: | ||
types: [opened, closed, reopened] | ||
issues: | ||
types: [opened, pinned, closed, reopened] | ||
jobs: | ||
notify: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Notify the commit on Telegram My Group. | ||
uses: EverythingSuckz/github-telegram-notify@main | ||
with: | ||
bot_token: '${{ secrets.BOT_TOKEN }}' | ||
chat_id: '${{ secrets.CHAT_ID }}' |