Add additional files #14
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 Telegram on Update | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
notify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get commit message | |
id: commit-message | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") | |
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV | |
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Get current time | |
id: current_time | |
run: echo "CURRENT_TIME=$(TZ=Asia/Jakarta date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV | |
- name: Check if README.md or main.yml was modified | |
id: check-files | |
run: | | |
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r HEAD) | |
if echo "$CHANGED_FILES" | grep -qE "^(README.md|.github/workflows/main.yml)$"; then | |
echo "README.md or main.yml was modified, skipping notification." | |
echo "SKIP_NOTIFICATION=true" >> $GITHUB_ENV | |
else | |
echo "No excluded files were modified, sending notification." | |
echo "SKIP_NOTIFICATION=false" >> $GITHUB_ENV | |
fi | |
- name: Notify Telegram | |
if: env.SKIP_NOTIFICATION == 'false' | |
env: | |
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | |
CHAT_ID: ${{ secrets.CHAT_ID }} | |
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }} | |
CURRENT_TIME: ${{ env.CURRENT_TIME }} | |
run: | | |
MESSAGE=$(cat <<-EOF | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬ | |
UPDATE INFO | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬ | |
DESC : \`$COMMIT_MESSAGE\` | |
DATE : \`${CURRENT_TIME}\` | |
REPO : \`Maizil41/RadiusMonitor\` | |
URL : [Click Here](https://github.com/Maizil41/RadiusMonitor) | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬ | |
EOF | |
) | |
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \ | |
-d chat_id=$CHAT_ID \ | |
-d parse_mode=Markdown \ | |
-d text="$MESSAGE" |