From f2f9e1edae544797e875c918817c91821a583601 Mon Sep 17 00:00:00 2001 From: PrajjuS Date: Sun, 25 Aug 2024 09:50:51 +0530 Subject: [PATCH] PullReqNotifier: Initial commit [skip ci] Change-Id: Ia8757e526ec70412eef0280e6c951319a80760e7 Signed-off-by: PrajjuS --- .github/workflows/pr_notify.yml | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/pr_notify.yml diff --git a/.github/workflows/pr_notify.yml b/.github/workflows/pr_notify.yml new file mode 100644 index 0000000..be637f6 --- /dev/null +++ b/.github/workflows/pr_notify.yml @@ -0,0 +1,41 @@ +name: Pull Request Notifier + +on: + pull_request_target: + types: + - opened + +jobs: + pull_req: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Get Info + run: | + sudo apt-get install jq -y &> /dev/null + echo "PR_TITLE=$(jq --raw-output .pull_request.title ${GITHUB_EVENT_PATH})" >> ${GITHUB_ENV} + echo "PR_URL=$(jq --raw-output .pull_request.html_url ${GITHUB_EVENT_PATH})" >> ${GITHUB_ENV} + + - name: Notify in Telegram + run: | + TgNotify() { + curl -s -X POST "https://api.telegram.org/bot${{ secrets.BOT_TOKEN }}/sendMessage" \ + -d chat_id="${1}" \ + -d parse_mode=Markdown \ + -d text="${2}" \ + -d disable_web_page_preview=true + } + + message=" + #PULL\_REQ + *New Pull Request Opened at* [${{ github.repository }}](https://github.com/${{ github.repository }}) + *Title:* \`${PR_TITLE}\` + *User:* [${{ github.actor }}](https://github.com/${{ github.actor }}) + *Pull Req URL:* [Here](${PR_URL})" + + for chat_id in ${{ secrets.PRIV_CHAT_IDS }}; do + TgNotify "${chat_id}" "${message}" + done +