This template runs your Python script automatically using GitHub Actions.
No server needed. No credit card. Completely free.
- Click the green "Use this template" button at the top of this page
- Click "Create a new repository"
- Give it a name and click "Create repository"
You now have your own copy to edit!
Upload or copy-paste your Python code into main.py
If you have other files your script needs (like .csv files or .txt templates),
add those to the repository too.
Change 1: Add this import at the top of your file:
import osChange 2: Replace any hardcoded passwords/API keys with this pattern:
# BEFORE (don't do this - secrets visible to everyone!)
MY_EMAIL = "myemail@gmail.com"
MY_PASSWORD = "mysecretpassword"
# AFTER (secrets stored securely in GitHub)
MY_EMAIL = os.environ.get("MY_EMAIL")
MY_PASSWORD = os.environ.get("MY_PASSWORD")Open requirements.txt and list any packages your script needs:
# For example:
pandas
requestsNever put passwords or API keys directly in your code!
GitHub Secrets keeps them safe and hidden.
- Go to your repository on GitHub
- Click Settings (top menu bar)
- Click Secrets and variables (left sidebar)
- Click Actions
- Click "New repository secret"
- Add each secret your script needs:
| Name | Value |
|---|---|
MY_EMAIL |
your email address |
MY_PASSWORD |
your email password or app password |
Gmail Users: You need an "App Password", not your regular password. Get one here: https://myaccount.google.com/apppasswords
Edit the file .github/workflows/scheduled.yml
Find this line near the top:
- cron: "0 9 * * *"Change the numbers to set your schedule:
┌─ minute (0-59)
│ ┌─ hour (0-23) in UTC time
│ │
cron: '0 9 * * *' means "run at 9:00 AM UTC every day"
Common schedules:
| What you want | Cron to use |
|---|---|
| 9:00 AM UTC | '0 9 * * *' |
| 2:30 PM UTC | '30 14 * * *' |
| Midnight UTC | '0 0 * * *' |
| 6:00 PM UTC | '0 18 * * *' |
Convert your local time to UTC: https://time.is/UTC
- Go to the Actions tab in your repository
- Click "Test Setup" in the left sidebar
- Click "Run workflow" → "Run workflow"
This checks that:
- Your secrets are configured
- All required files exist
- Your Python code has no syntax errors
If everything passes, you're ready to go!
Once the test passes, try running your actual script:
- Go to the Actions tab
- Click "Daily Script" in the left sidebar
- Click "Run workflow" → "Run workflow"
Watch it run! Click on the job to see the output.
- Go to the Actions tab
- You'll see a list of all runs with green (success) or red (failed)
- Click on any run to see details
- Click on "run" to expand and see your script's output
- GitHub schedules can be delayed by 5-15 minutes (this is normal)
- Your repository must have activity every 60 days, or GitHub pauses the schedule
- Fix: Make any small commit to re-enable it
- Add the missing package to
requirements.txt - Make sure spelling matches exactly (case-sensitive)
- Secret names are case-sensitive:
MY_EMAILis different frommy_email - In your code, use the exact same name:
os.environ.get("MY_EMAIL") - In the workflow file, the secret must be passed to the script (already done in template)
- Gmail requires an App Password, not your regular password
- Check that "Less secure apps" is enabled (some providers)
- Check the Actions log for error messages
To run at 9:00 AM in your local time, use this hour in UTC:
| Your Location | UTC Offset | Hour to use |
|---|---|---|
| London (GMT/BST) | +0 / +1 | 9 or 8 |
| Paris, Berlin (CET) | +1 | 8 |
| New York (EST/EDT) | -5 / -4 | 14 or 13 |
| Chicago (CST/CDT) | -6 / -5 | 15 or 14 |
| Denver (MST/MDT) | -7 / -6 | 16 or 15 |
| Los Angeles (PST/PDT) | -8 / -7 | 17 or 16 |
| Sydney (AEST/AEDT) | +10 / +11 | 23 or 22 (prev day) |
| Tokyo (JST) | +9 | 0 (midnight) |
| India (IST) | +5:30 | 3 (minute: 30) |
Two values shown for locations with daylight saving time