From 85ae2134126503cf70d949283d15f5e33d93993f Mon Sep 17 00:00:00 2001 From: luna <101097846+lunaticsm@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:05:18 +0700 Subject: [PATCH] Update notify.yml --- .github/workflows/notify.yml | 90 +++++++++++------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml index 198a3d2..3f29fe6 100644 --- a/.github/workflows/notify.yml +++ b/.github/workflows/notify.yml @@ -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 }}'