Skip to content

🚀Telegram Notif update #37

🚀Telegram Notif update

🚀Telegram Notif update #37

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: Set server and site environment variables
run: |
echo "SERVER_NAME=${{ secrets.SERVER_NAME }}" >> $GITHUB_ENV
echo "SITE_NAME=${{ secrets.SITE_NAME }}" >> $GITHUB_ENV
- name: Send Telegram Notification
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_GROUP_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
disable_web_page_preview: true
# format: html
message: |
${{ env.COMMIT_AUTHOR }} deploy some fresh code!
*Server: ${{ env.SERVER_NAME }}
*Site: ${{ env.SITE_NAME }}
*Commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
*Message: ${{ env.PR_TITLE }}.