-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
65 lines (57 loc) · 2.44 KB
/
Copy pathaction.yaml
File metadata and controls
65 lines (57 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Notify
inputs:
telegram_message:
required: false
default: |
${{ github.event_name }}
${{ github.repository_owner }}
${{ github.repository }}
Commit message: ${{ github.event.commits[0].message }}
[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
telegram_photo:
required: false
telegram_document:
required: false
## secrets
TELEGRAM_TOKEN:
required: true
TELEGRAM_TO:
required: true
runs:
using: 'composite'
steps:
- name: Setting jdate_source
shell: bash
run: echo "jdate_source=docker-jdate" >> $GITHUB_ENV
- name: Pulling/cloning/downloading jdate
uses: davoudarsalani/action-jdate@master
with:
source: '${{ env.jdate_source }}'
- name: Getting date/time
shell: bash
run: |
case '${{ env.jdate_source }}' in
docker-khayyam ) date_time="$(docker run --rm -t davoudarsalani/khayyam python -c "import khayyam; print(khayyam.JalaliDatetime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")" ;;
docker-persiantools ) date_time="$(docker run --rm -t davoudarsalani/persiantools python -c "from persiantools.jdatetime import JalaliDateTime; print(JalaliDateTime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")" ;;
docker-jdatetime ) date_time="$(docker run --rm -t davoudarsalani/jdatetime python -c "import jdatetime; print(jdatetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S %A'))")" ;;
docker-jdate ) date_time="$(docker run --rm -t davoudarsalani/jdate jdate '+%Y-%m-%d %H:%M:%S %A')" ;;
* ) date_time="$(jdate '+%Y-%m-%d %H:%M:%S %A')" ;;
esac
echo "date_time=$date_time" >> $GITHUB_ENV
- name: Sending telegram message
shell: bash
run: |
wget -q 'https://raw.githubusercontent.com/davoudarsalani/scripts/master/telegram.sh'
chmod +x ./telegram.sh
## telegram is told, by -M flag, to process markdown messages
## so let's make sure special characters like *, @ and _ are escaped
message_text='${{ inputs.telegram_message }}'
message_text="$(printf '%s\n' "$message_text" | sed 's|\([_@\*]\)|\\\1|g' )"
./telegram.sh \
-t '${{ inputs.TELEGRAM_TOKEN }}' \
-c '${{ inputs.TELEGRAM_TO }}' \
-T '${{ env.date_time }}' \
-f '${{ inputs.telegram_document }}' \
-i '${{ inputs.telegram_photo }}' \
-M \
"$message_text"