🚀Telegram Notif update #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_CHAT_ID }} | |
token: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
message: "${{ env.COMMIT_AUTHOR }} deploy some fresh code!. \n\n\\*Server:\\* ${{ env.SERVER_NAME }} \n*Site:* ${{ env.SITE_NAME }} \n*Commit:* https://github.com/${{ github.repository }}/commit/${{ github.sha }} \n*Message:* ${{ env.PR_TITLE }}." | |
parse_mode: MarkdownV3 |