Skip to content

Commit

Permalink
Update generate_event_reminders.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremymanning authored Jul 18, 2024
1 parent d7348e5 commit e116e7e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions generate_event_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ def create_event_script(event_name, date_str, content_file, frequency, day_of_we
with open(script_path, 'w') as file:
file.write(script_content)

# Generate appropriate cron time
cron_time = f'{event_date.minute} {event_date.hour} {event_date.day} {event_date.month} *'

# Create the workflow for the event
workflow_content = {
'name': f'Reminder for {event_name}',
'on': {
'workflow_dispatch': {},
'schedule': [
{'cron': cron_time} # Set the cron time
]
},
'jobs': {
'send_email': {
'runs-on': 'ubuntu-latest',
'steps': [
{'name': 'Checkout repository', 'uses': 'actions/checkout@v2'},
{'name': 'Set up Python', 'uses': 'actions/setup-python@v2', 'with': {'python-version': '3.x'}},
{'name': 'Install dependencies', 'run': 'pip install pandas markdown'},
{'name': 'Run email script', 'run': f'python scripts/send_email_{event_name.replace(" ", "_")}.py', 'env': {'GMAIL_PASSWORD': '${{ secrets.GMAIL_PASSWORD }}'}}
]
}
}
}

workflow_path = f'.github/workflows/reminder_{event_name.replace(" ", "_")}.yml'
print(f"Creating workflow at {workflow_path}")
with open(workflow_path, 'w') as file:
yaml.dump(workflow_content, file)

# Generate scripts for each event
for _, row in events_df.iterrows():
event_name = row['Event Name']
Expand Down

0 comments on commit e116e7e

Please sign in to comment.