Overview
The F1 Stats Archive uses GitHub Actions to automatically update race data on a scheduled basis. This ensures the archive stays current with the latest Formula 1 statistics from the Ergast API.GitHub Actions Workflow
The automation is configured in.github/workflows/run.yml:
How It Works
1. Scheduled Execution
The workflow runs automatically based on the cron schedule:The cron expression can be modified to run at different intervals. For example,
0 0 * * 1 would run every Monday at midnight UTC.2. Data Collection Scripts
The workflow executes all Python scripts sequentially:driver_points.py- Fetches driver championship standingsevents.py- Retrieves race schedule and event informationlaptimes.py- Collects all lap times for racespitstops.py- Gathers pit stop dataquali_results.py- Gets qualifying session resultsresults.py- Fetches race resultssprint_results.py- Collects sprint race resultsteam_points.py- Retrieves constructor championship standings
- Respects Ergast API rate limits
- Creates the appropriate directory structure
- Saves data as JSON files
- Handles errors and retries gracefully
3. Automatic Commits
If new data is fetched, the workflow automatically:- Configures Git with the GitHub Actions bot identity
- Stages all changes
- Creates a commit with the message “Update team points data”
- Pushes changes back to the repository
The workflow only creates a commit if there are actual changes to the data.
Manual Triggering
You can manually trigger the workflow using the GitHub UI:- Go to your repository on GitHub
- Click the Actions tab
- Select the Update Stats workflow
- Click Run workflow
- Choose the branch and click Run workflow
Configuring for Your Own Use
1. Fork the Repository
2. Adjust the Schedule
Edit.github/workflows/run.yml to change when data updates occur:
3. Customize Data Collection
Modify the scripts to collect specific data: Example: Only collect data for recent seasons Edit the year range in each script:4. Set Up Repository Permissions
Ensure GitHub Actions has permission to commit:- Go to Settings > Actions > General
- Scroll to Workflow permissions
- Select Read and write permissions
- Check Allow GitHub Actions to create and approve pull requests
- Click Save
Monitoring Workflow Runs
View Run History
Check the status of past workflow runs:View Run Logs
Check for Failures
The workflow may fail if:- The Ergast API is unavailable
- Rate limits are exceeded
- Network connectivity issues occur
- Data format changes unexpectedly
Best Practices
Optimize for Rate Limits
If you’re collecting large amounts of data:Enable Notifications
Get notified when workflows fail:- Go to your GitHub notification settings
- Enable Actions notifications
- Choose email or web notifications
Use Workflow Artifacts
Store logs or intermediate data:Troubleshooting
Workflow Not Running on Schedule
- Verify the cron syntax is correct
- Ensure the workflow file is in the default branch
- Check that Actions are enabled for your repository
Commits Not Pushing
- Verify repository permissions (see setup section)
- Check for branch protection rules that might block automated commits
- Ensure the GitHub Actions bot has write access
Rate Limit Errors
If you see 429 errors:- Reduce the frequency of scheduled runs
- Increase delays in the Python scripts
- Focus on collecting only recent data