Skip to content

test: test notif for telegram #1

test: test notif for telegram

test: test notif for telegram #1

Workflow file for this run

name: Notify on Merge
on:
pull_request:
types: [closed]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Identify merged commit
run: |
git fetch origin main
MERGED_COMMIT=$(git log origin/main..HEAD --pretty=format:"%H" -1)
COMMIT_AUTHOR=$(git log --format="%an <%ae>" -n 1 $MERGED_COMMIT)
COMMIT_MESSAGE=$(git log --format=%B -n 1 $MERGED_COMMIT)
PR_SOURCE_BRANCH=$(jq -r ".pull_request.head.ref" "$GITHUB_EVENT_PATH")
PR_TARGET_BRANCH=$(jq -r ".pull_request.base.ref" "$GITHUB_EVENT_PATH")
echo "MERGED_COMMIT=$MERGED_COMMIT" >> $GITHUB_ENV
echo "COMMIT_AUTHOR=$COMMIT_AUTHOR" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
echo "PR_SOURCE_BRANCH=$PR_SOURCE_BRANCH" >> $GITHUB_ENV
echo "PR_TARGET_BRANCH=$PR_TARGET_BRANCH" >> $GITHUB_ENV
- name: Send Telegram Notification
run: |
curl -s -X POST https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage -d chat_id=$TELEGRAM_CHAT_ID -d text="Arseno telah melakukan merge dari branch $PR_SOURCE_BRANCH ke $PR_TARGET_BRANCH di repository ini. Commit terbaru: $MERGED_COMMIT, Pesan commit: $COMMIT_MESSAGE"
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}