Overview
We can use a scheduled job to run every Monday morning to send out a product announcement email if any new release is detected. For the sake of simplicity, we’re going to use the public GitHub API to check the latest published release of an open source project to demonstrate how this might work.Just show me the code
Just show me the code
See the finished code on Replit.You can even use the Replit URL to run your job, as long as the Repl is running. Make sure to replace
YOUR_EMAIL_ADDRESS
with a valid email address and YOUR_RESEND_API_KEY
with your Resend API key, and then you can run the following in your terminal:cURL
CLI
Checking a project’s latest release
We can use use the following API endpoint to get the latest release for a project, given the GitHubowner
and repo
names:
name
and body
markdown field for our email notification, and the release id
to reference the last notification that was sent.
Here’s how we could retrieve that data in TypeScript:
Triggering emails for new releases
Now what we want to do is:- Fetch the latest release of the repository using the
fetchLatestRelease
function above. - Use the schedule’s
state
to store the ID of last sent release, which we check against the current latest release. - If the current latest release is different from the last sent release, we trigger an email to be sent out to the recipients of our choosing.
Note that in the reponse we use the special
$set
key to update the state
of the job schedule, so that we can reference the last_sent_release
ID in
future jobs.Formatting the email HTML
Right now our email is just getting sent in plaintext markdown:
/components/emails/MarkdownEmail.tsx

Don't want to use React? Use `marked` instead
Don't want to use React? Use `marked` instead
If we want to keep things simple, we can use the Note that it may require a bit of styling to prevent images from overflowing:
marked
library to parse the markdown into HTML:Creating the scheduled job
Using our new API endpoint, we can schedule a job to run it every Monday at 10am using a cron expression, using the schedule$state
to reference the last sent release ID: