Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix mailchimp campaign schedule with meetings list #332

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/create-event-helpers/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,15 @@ async function listEvents() {
let eventsItems;

try {
//this runs always on friday midnight
//this runs always on sunday midnight
const currentTime = new Date(Date.now()).toISOString();
//we check moday
const timeIn2Days = new Date(Date.parse(currentTime) + 2 * 24 * 60 * 60 * 1000).toISOString();
//till friday
const timeIn8Days = new Date(Date.parse(currentTime) + 8 * 24 * 60 * 60 * 1000).toISOString();
const endTime = new Date(Date.parse(currentTime) + 6 * 24 * 60 * 60 * 1000).toISOString();

const eventsList = await calendar.events.list({
calendarId: process.env.CALENDAR_ID,
timeMax: timeIn8Days,
timeMin: timeIn2Days
timeMax: endTime,
timeMin: currentTime
})

eventsItems = eventsList.data.items.map((e) => {
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/create-event-helpers/mailchimp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ module.exports = async () => {
* We schedule an email, we do not send it at midnight immediately but use schedule with `timewarp` to basically send email at the same time for anyone no matter what time zone they live in
*/
try {
const scheduleDate = new Date(Date.now());
//next day 11:00
const scheduleDate = new Date(Date.parse(new Date(Date.now()).toISOString()) + 1 * 24 * 60 * 60 * 1000);
scheduleDate.setUTCHours(11);
scheduleDate.setUTCMinutes(00);

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/send-events-newsletter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Send email to newsletter subscribers about upcomming meetings

on:
schedule:
# Runs "At 00:00 on Friday." (see https://crontab.guru)
- cron: '00 00 * * 5'
# Runs "At 00:00 on Sunday." (see https://crontab.guru)
- cron: '00 00 * * 7'

jobs:

Expand Down