A totally automated GitHub actions workflow that emails you daily tech (or any other category) news summaries to your inbox using GitHub Actions, NewsAPI, and SMTP.
sequenceDiagram
participant GitHub Actions
participant NewsAPI
participant SMTP Server
participant Your Inbox
GitHub Actions->>NewsAPI: 1. Request tech news
NewsAPI-->>GitHub Actions: 2. Return news data
GitHub Actions->>SMTP Server: 3. Send formatted email
SMTP Server->>Your Inbox: 4. Deliver email
Note right of GitHub Actions: Runs daily at 18:00 UTC
- Fetches the top 5 trending tech news articles daily from NewsAPI.org.
- Can be modified to fetch different news categories.
- Sends you a daily email with article summaries and links.
- Runs daily at 18:00 UTC via GitHub Actions.
- Uses SMTP authentication to send emails securely.
- Supports Gmail, Outlook, Yahoo, and custom SMTP servers.
- Email credentials are stored securely in GitHub Secrets.
- Runs automatically without manual actions.
- But can also be manually triggered via GitHub Actions workflow dispatch.
- Hosted on GitHub’s free CI/CD runners.
- Catches API failures (i.e., network issues, API rate limits).
- Logs the error messages for debugging.
- Provides warnings if no news articles are found.
Go to Settings > Secrets and variables > Actions and add:
Secret Name | Value |
---|---|
NEWSAPI_KEY |
Your NewsAPI key (https://newsapi.org). |
SENDER_EMAIL |
Your email address for sending news. |
RECEIVER_EMAIL |
The recipient’s email address. |
SMTP_SERVER |
SMTP server (i.e., smtp.gmail.com ). |
SMTP_PORT |
SMTP port (465 for SSL or 587 for TLS). |
SMTP_PASSWORD |
Your email password or app password. |
- Update the schedule.yml if needed (default is 18:00 UTC daily).
- Modify environment variables if using a different/custom SMTP provider.
- The workflow runs automatically at 18:00 UTC.
- But you can also manually trigger it under GitHub Actions > Run Workflow.
You can change news category by modifying the NewsAPI query in the main.py
script.
Open main.py
and locate this line:
category = "technology"
Possible categories with NewsAPI are: business
, entertainment
, general
, health
, science
, sports
, and technology
.
1. Can I change the frequency of the email updates?
Yes, just openschedule.yml
and modify the cron
schedule to change the timing.
Example for hourly runs:
- cron: '0 * * * *'
2. Can I use this bot with other news APIs?
Yes, but you’ll need to modify theget_news()
function in main.py
to make API requests to the new service and parse their response format.
3. Can I customize the email content?
Yes, just edit theget_tech_news()
or send_email()
functions in main.py.
You can change the formatting, number of articles, or add new details to the email body.
4. Can I host this on a local machine instead of GitHub Actions?
Yes, install the required dependencies and set up acron
job to run main.py
on your local machine. Use a .env
file to manage your credentials securely.
5. How do I set up my email credentials securely?
Store your credentials (STMP_SERVER
,NEWSAPI_KEY
,etc...) in GitHub Secrets as shown in the setup and configuration steps above.
IMPORTANT: NEVER hard-code any sensitive information directly in your code.
6. How is SMTP security handled, and is it safe to store sensitive information in GitHub Secrets?
SMTP credentials (such as email, password, server, and port number) are stored securely in GitHub Secrets, which are encrypted and accessible only as environment variables during workflow action. You can also use this bot with an email address that you don’t frequently use (SENDER_EMAIL
) while adding your primary email (RECEIVER_EMAIL
) address as the recipient in GitHub Secrets. Steps for this are shown in the setup and configuration steps above. And while it may not always be necessary, I recommend using App Passwords instead of your actual email password for added protection.
7. What are App Passwords?
App Passwords are platform-specific passwords that allows third-party apps (like this bot) to access your email account without exposing your main account password.Provider | Steps to Generate App Password |
---|---|
Gmail |
|
Outlook/Hotmail |
|
Yahoo Mail |
|
8. Is it possible to use this bot with multiple recipients?
Yes, but with some modification. First, you need to add the recipients toRECEIVER_EMAIL
in GitHub secrets, seperated by commas. Let's say you have: [email protected], [email protected]. Then you need to modify the send_email
function in main.py
so that it can handle multiple recipients. Now, the below line splits the receiver_email
string (Stored in GitHub Secrets) into a list of email addresses, allowing you to handle multiple recipients.
recipients = email_config['receiver_email'].split(",")
for recipient in recipients:
recipient = recipient.strip() # Remove spaces
msg['To'] = recipient
server.send_message(msg)
logging.info(f"Email sent to {recipient}")
logging.info(f"Email sent to {recipient}")
9. What if there are no articles available in the selected category?
The bot will log a warning:No articles found for category:
and skip sending the email.
10. Can I change the number of news articles in the email?
Yes, modify the[:5]
in the get_news()
function to your desired number of articles.
Example:
articles = response.json().get('articles', [])[:10] # Gets top 10 articles
11. Can I change the email format to HTML instead of plain text?
Yes, modify thesend_email()
function and change the email body format from plain to html.
Feel free to contribute, suggest improvements, or submit PRs.
If you found the project helpful, I'd appreciate a follow :)