Skip to content

Follow Iran Calendar Center website #1707

Follow Iran Calendar Center website

Follow Iran Calendar Center website #1707

name: Follow Iran Calendar Center website
on:
schedule:
- cron: '43 */6 * * *' # every six hours
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update the text and notify if is changed
run: |
sudo apt install html2text
curl --fail https://calendar.ut.ac.ir/Fa/ | html2text | sed -E "s/ +[0-9]+ نفر/0 نفر/g" > .github/follow-iran-calendar-data.txt
# If is empty, revert to what was there at least
[ -s .github/follow-iran-calendar-data.txt ] || git checkout .github/follow-iran-calendar-data.txt
[ -z "$(git status -s)" ] || curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage \
-d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
-d parse_mode=HTML \
-d "text=There is an update in https://calendar.ut.ac.ir" | \
jq -r '"message_id=\(.result.message_id)"' | \
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/pinChatMessage \
-d disable_notification=false \
-d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
--data-binary @-
- name: Update the repo also
uses: EndBug/add-and-commit@2d7c2e89fcb436f8e139cc80813bd030bdd40c4b
with:
default_author: github_actions
message: 'ci: Update Iran Calendar Center data'
add: .github/follow-iran-calendar-data.txt