-
Notifications
You must be signed in to change notification settings - Fork 3
204 lines (175 loc) Β· 8.64 KB
/
matrix_dev_sync_reminder.yml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: matrix_dev_sync_reminder
on:
schedule:
- cron: "0 14 * * 3" # Wednesdays at 14:00 UTC
workflow_dispatch: # manual triggering
env:
FIRST_RUN_DATE: "2024-11-13"
jobs:
check-repository:
runs-on: ubuntu-latest
outputs:
is_correct_repo: ${{ steps.check.outputs.is_correct_repo }}
steps:
- name: Check repository
id: check
run: |
if [ "$GITHUB_REPOSITORY" = "scribe-org/Organization" ]; then
echo "is_correct_repo=true" >> "$GITHUB_OUTPUT"
else
echo "is_correct_repo=false" >> "$GITHUB_OUTPUT"
echo "::warning::This workflow should only run in scribe-org/Organization repository."
fi
weekindex:
needs: check-repository
if: needs.check-repository.outputs.is_correct_repo == 'true'
runs-on: ubuntu-latest
outputs:
weekindex: ${{ steps.calculate.outputs.weekindex }}
next_bi_weekly_date: ${{ steps.calculate.outputs.next_bi_weekly_date }}
next_next_bi_weekly_date: ${{ steps.calculate.outputs.next_next_bi_weekly_date }}
steps:
- name: Calculate Next Date
id: calculate
run: |
current_date=$(date +%Y-%m-%d)
start=$(date -d "${{ env.FIRST_RUN_DATE }}" +%s)
end=$(date -d "$current_date" +%s)
weekdiff=$(((end - start) / 60 / 60 / 24 / 7))
weekindex=$((weekdiff % 2))
# Calculate next bi-weekly date.
if [ "$weekindex" -eq 0 ]; then
next_bi_weekly_date=$(date -d "$current_date + 3 days" +%Y-%m-%d)
next_next_bi_weekly_date=$(date -d "$current_date + 17 days" +%Y-%m-%d)
else
next_bi_weekly_date=$(date -d "$current_date + 10 days" +%Y-%m-%d)
next_next_bi_weekly_date=$(date -d "$current_date + 24 days" +%Y-%m-%d)
fi
echo "weekindex=$weekindex" >> "$GITHUB_OUTPUT"
echo "next_bi_weekly_date=$next_bi_weekly_date" >> "$GITHUB_OUTPUT"
echo "next_next_bi_weekly_date=$next_next_bi_weekly_date" >> "$GITHUB_OUTPUT"
echo "FIRST_RUN_DATE: ${{ env.FIRST_RUN_DATE }}" >> $GITHUB_STEP_SUMMARY
echo "current_date: $current_date" >> $GITHUB_STEP_SUMMARY
echo "weekdiff: $weekdiff" >> $GITHUB_STEP_SUMMARY
echo "weekindex: $weekindex" >> $GITHUB_STEP_SUMMARY
echo "next_bi_weekly_date: $next_bi_weekly_date" >> $GITHUB_STEP_SUMMARY
if [ "$weekindex" -eq 0 ]; then
echo "π’ It's the first week of the bi-weekly cycle. The action will run." >> $GITHUB_STEP_SUMMARY
else
echo "π΄ It's the second week of the bi-weekly cycle. The action will be skipped." >> $GITHUB_STEP_SUMMARY
fi
send-message:
if: ${{ needs.weekindex.outputs.weekindex == '0' }}
runs-on: ubuntu-latest
needs:
- weekindex
- check-repository
steps:
- name: Format EPOCH Time
id: epoch-time
run: |
current_epoch_time=$(date +%s)
next_epoch_time=$(date -d "${{ needs.weekindex.outputs.next_bi_weekly_date }} 15:00:00" +%s)
next_next_epoch_time=$(date -d "${{ needs.weekindex.outputs.next_next_bi_weekly_date }} 15:00:00" +%s)
echo "EPOCH_TIME=$current_epoch_time" >> $GITHUB_ENV
echo "NEXT_BI_WEEKLY_DATE=${{ needs.weekindex.outputs.next_bi_weekly_date }}" >> $GITHUB_ENV
echo "NEXT_EPOCH_TIME=$next_epoch_time" >> $GITHUB_ENV
echo "NEXT_NEXT_BI_WEEKLY_DATE=${{ needs.weekindex.outputs.next_next_bi_weekly_date }}" >> $GITHUB_ENV
echo "NEXT_NEXT_EPOCH_TIME=$next_next_epoch_time" >> $GITHUB_ENV
echo "Current EPOCH time: $current_epoch_time" >> $GITHUB_STEP_SUMMARY
echo "Next bi-weekly date: ${{ needs.weekindex.outputs.next_bi_weekly_date }}" >> $GITHUB_STEP_SUMMARY
echo "Next EPOCH time (for sync): $next_epoch_time" >> $GITHUB_STEP_SUMMARY
echo "Next next bi-weekly date: ${{ needs.weekindex.outputs.next_next_bi_weekly_date }}" >> $GITHUB_STEP_SUMMARY
echo "Next next EPOCH time (for sync): $next_next_epoch_time" >> $GITHUB_STEP_SUMMARY
- name: Etherpad Creation
env:
NEXT_BI_WEEKLY_DATE: ${{ env.NEXT_BI_WEEKLY_DATE }}
NEXT_EPOCH_TIME: ${{ env.NEXT_EPOCH_TIME }}
NEXT_NEXT_BI_WEEKLY_DATE: ${{ env.NEXT_NEXT_BI_WEEKLY_DATE }}
NEXT_NEXT_EPOCH_TIME: ${{ env.NEXT_NEXT_EPOCH_TIME }}
run: |
pip install requests
python - <<EOF
import requests
import os
next_epoch_time = os.environ.get('NEXT_EPOCH_TIME')
next_bi_weekly_date = os.environ.get('NEXT_BI_WEEKLY_DATE')
next_next_epoch_time = os.environ.get('NEXT_NEXT_EPOCH_TIME')
next_next_bi_weekly_date = os.environ.get('NEXT_NEXT_BI_WEEKLY_DATE')
pad_name = f'scribe-dev-sync-{next_bi_weekly_date}'
url = f'https://etherpad.wikimedia.org/p/{pad_name}/import'
print(f"Importing content to: https://etherpad.wikimedia.org/p/{pad_name}")
# The text you want to add to the pad.
content = f"""<html><body>
<h1><strong>Scribe Dev Sync {next_bi_weekly_date}</strong></h1>
<br>
<br>
<p>Pad directory: https://etherpad.wikimedia.org/p/scribe-dev-sync</a><br>
ZoneStamp: https://zonestamp.toolforge.org/{next_epoch_time}</a></p>
<br>
<h2>Participants (please list yourself if you'd like to)</h2>
<ul>
<li>Participant</li>
</ul>
<br>
<h2>Topics</h2>
<ul>
<li>All: Introductions π</li>
<li>All: Does anyone want a calendar invite to the dev sync?
<ul>
<li>If you would like an invite, please message the team on Matrix/Element</li>
</ul>
</li>
<li>Recap done by: NAME</li>
<li>Go through the project board: https://github.com/orgs/scribe-org/projects/1</a></li>
<li>Name:</li>
</ul>
<br>
<h2>Tasks (strikethrough ^/β + 5 to mark as complete)</h2>
<ul>
<li>Task</li>
</ul>
<br>
<h2><strong>Recap</strong></h2>
<br>
<br>
<p>Here's the recap for today's/Saturday's dev sync π§βπ»β»οΈ</p>
<br>
<p>
- [Pad for this week](https://etherpad.wikimedia.org/p/scribe-dev-sync-${{ env.NEXT_BI_WEEKLY_DATE }})
- Note
</p>
<br>
<p>The next dev sync will be [Saturday {next_next_bi_weekly_date} at 15:00 UTC](https://zonestamp.toolforge.org/${{ env.NEXT_NEXT_EPOCH_TIME }}).</p>
<br>
<p>Nice outro π</p>
</body></html>"""
# Prepare the file to upload.
files = {
'file': ('import.html', content.encode('utf-8'), 'text/html'),
}
response = requests.post(url, files=files)
if response.status_code in [200, 302]:
print(f"Content imported successfully into pad '{pad_name}'.")
elif response.status_code == 413:
print("The file is too large to upload.")
else:
print(f"Failed to import content. Status code: {response.status_code}")
print(response.text)
EOF
- name: Send Message to Matrix Channel
id: matrix-chat-message
uses: fadenb/matrix-chat-message@v0.0.6
with:
homeserver: "matrix.org"
token: ${{ secrets.MATRIX_SCRIBE_BOT_ACCESS_TOKEN }}
channel: ${{ secrets.MATRIX_GENERAL_ROOM_ID }}
message: |
Hello all! π€π Here's the reminder for [this Saturday's dev sync at 15:00 UTC](https://zonestamp.toolforge.org/${{ env.NEXT_EPOCH_TIME }}) π§βπ»β»οΈ
For those new to the community, every two Saturdays the Scribe team does a call to discuss the projects. We use [Element Call](https://call.element.io/) and a [pad from Wikimedia's Etherpad instance](https://etherpad.wikimedia.org/p/scribe-dev-sync-${{ env.NEXT_BI_WEEKLY_DATE }}) for taking notes. Note that Element Call doesn't have a chat, so questions need to be written in the pad :)
Details for the upcoming sync:
- Call link: https://call.element.io/room/#/scribe-dev-sync?password=6fYAt2r2lnhntXpNu1b1BrCkDy1NHTXJ&roomId=%21MEatqydcuQXoqGtjfR%3Acall.ems.host
- This week's pad: https://etherpad.wikimedia.org/p/scribe-dev-sync-${{ env.NEXT_BI_WEEKLY_DATE }}
- All Scribe pads: https://etherpad.wikimedia.org/p/scribe-dev-sync
Please reply in the thread for this message with anything you'd like to discuss π§΅
Thanks and have a great day! π