-
Notifications
You must be signed in to change notification settings - Fork 9
132 lines (104 loc) Β· 5.43 KB
/
send-messages.yaml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Send Reminders on Twitter and Telegram
on:
schedule:
# Schedule job 10 minutes before time to account for delays
# Every Saturday at 11:20 AM UTC (05:00 PM IST minus 10 min)
- cron: "20 11 * * SAT"
# Every Saturday at 04:30 PM UTC (10:10 PM IST minus 10 min)
- cron: "30 16 * * SAT"
workflow_dispatch:
inputs:
message-template:
type: choice
required: true
default: automatic
options:
- automatic
- reminder
- joining
description: |
Which message template to use.
if set to `automatic`, resolves to:
`joining`, if time is after 10pm on Saturday (IST)
`reminder`, otherwise
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
jobs:
send-messages:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set environment variables
run: |
upcoming_catchup_number=$(node util/get-next-catchup-number.js)
echo "UPCOMING_CATCHUP_NUMBER=${upcoming_catchup_number}" >> ${GITHUB_ENV}
prev_catchup_number=$(node util/get-latest-catchup-number.js)
echo "PREV_CATCHUP_NUMBER=${prev_catchup_number}" >> ${GITHUB_ENV}
catchup_date=$(date +"%b %d")
echo "CATCHUP_DATE=${catchup_date}" >> ${GITHUB_ENV}
message_template=${{ inputs.message-template }}
if [ "${message_template}" = "automatic" ] || [ -z "${message_template}" ]; then
message_template=$(node util/get-current-message-template.js)
fi
echo "MESSAGE_TEMPLATE=${message_template}" >> ${GITHUB_ENV}
# Reminder messages
- name: Wait until 17:00 IST
if: ${{ env.MESSAGE_TEMPLATE == 'reminder' }}
run: sleep $(node util/get-seconds-until-ist-time.js 17:00)
- name: Send reminder Telegram message
if: ${{ env.MESSAGE_TEMPLATE == 'reminder' }}
run: |
export TELEGRAM_MESSAGE="Reminder! π¨
The ${{ env.UPCOMING_CATCHUP_NUMBER }} OTC CatchUp session will be held today (${{ env.CATCHUP_DATE }}) from 10:30 PM IST.
Join us for an informal open-to-all Tech discussion!
Joining link π
https://catchup.ourtech.community/attend
Previous session details π
https://catchup.ourtech.community/summary/${{ env.PREV_CATCHUP_NUMBER }}"
BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} node util/post-telegram-message.js
- name: Send reminder Tweet
if: ${{ env.MESSAGE_TEMPLATE == 'reminder' }}
uses: Eomm/why-don-t-you-tweet@v1
with:
tweet-message: |
Reminder! π¨
The ${{ env.UPCOMING_CATCHUP_NUMBER }} OTC CatchUp session will be held today (${{ env.CATCHUP_DATE }}) from 10:30 PM IST.
Join us for an informal open-to-all Tech discussion!
Previous session details π
https://catchup.ourtech.community/summary/${{ env.PREV_CATCHUP_NUMBER }}
#OTC #OTCCatchUp #Community #Tech
env:
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_API_KEY_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
# Joining messages
- name: Wait until 22:10 IST
if: ${{ env.MESSAGE_TEMPLATE == 'joining' }}
run: sleep $(node util/get-seconds-until-ist-time.js 22:10)
- name: Send joining Telegram message
if: ${{ env.MESSAGE_TEMPLATE == 'joining' }}
run: |
export TELEGRAM_MESSAGE="<b>${{ env.UPCOMING_CATCHUP_NUMBER }} OTC CatchUp</b>
An informal open-to-all Tech discussion!
We start at 10:30 PM IST.
Join in at any time! π
https://catchup.ourtech.community/attend"
BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} node util/post-telegram-message.js
- name: Send joining Tweet
if: ${{ env.MESSAGE_TEMPLATE == 'joining' }}
uses: Eomm/why-don-t-you-tweet@v1
with:
tweet-message: |
Going live in 30 mins!
Join us for the ${{ env.UPCOMING_CATCHUP_NUMBER }} #OTCCatchUp, an informal open-to-all Tech discussion.
Join in at any time! π
https://catchup.ourtech.community/attend
env:
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_API_KEY_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}