Skip to content

🚀Telegram Notif update #23

🚀Telegram Notif update

🚀Telegram Notif update #23

Workflow file for this run

name: Notify on Merge
on:
pull_request:
types: [closed]
branches:
- '*'
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch updates from origin
run: git fetch origin development
- name: Get PR number
id: pr
run: |
PR_NUMBER=$(curl --silent --location --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" | jq '.[0].number')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Get PR source branch
id: pr_source_branch
run: |
PR_SOURCE_BRANCH=$(curl --silent --location --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ env.PR_NUMBER }}" | jq -r .head.ref)
echo "PR_SOURCE_BRANCH=$PR_SOURCE_BRANCH" >> $GITHUB_ENV
- name: Get PR target branch
id: pr_target_branch
run: echo "PR_TARGET_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Get commit author
id: commit_author
run: echo "COMMIT_AUTHOR=$(git show --no-patch --format='%an' ${{ steps.pr.outputs.PR_NUMBER }})" >> $GITHUB_ENV
- name: Get commit message
id: commit_message
run: echo "COMMIT_MESSAGE=$(git show --no-patch --format='%s' ${{ steps.pr.outputs.PR_NUMBER }})" >> $GITHUB_ENV
- name: Retrieve Pull Request Title
id: pr_title
run: |
PR_TITLE=$(curl --silent --location --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ env.PR_NUMBER }}" | jq -r .title)
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
- name: Send Telegram Notification
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: "${{ env.COMMIT_AUTHOR }} deploy some fresh code! \n ${{ env.PR_TARGET_BRANCH }}. \n\nCommit: https://github.com/${{ github.repository }}/commit/${{ github.sha }} \nMessage: ${{ env.PR_TITLE }} (#${{ env.PR_NUMBER }})."