Generate ICS #2768
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate ICS | |
on: | |
schedule: | |
- cron: '*/20 * * * *' # Runs every 20 minutes | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Use the latest Ubuntu environment | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Use the latest version | |
- name: Set up Python | |
uses: actions/setup-python@v5 # Use the latest version | |
with: | |
python-version: '3.12' # Specify Python 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip # Upgrade pip to the latest | |
pip uninstall -y ics # Clean up the old package if exists | |
pip install -r requirements.txt # Install required libraries | |
- name: Run script | |
run: python main.py # Run the Python script to generate the .ics file | |
- name: Commit and push ICS file to gh-pages branch | |
run: | | |
git config --global user.email "[email protected]" # Set a generic email for commits | |
git config --global user.name "GitHub Actions" # Set a generic name for commits | |
git checkout gh-pages || git checkout -b gh-pages # Switch to gh-pages branch (create it if it doesn't exist) | |
git add soccer_schedule.ics # Stage the .ics file for commit | |
git commit -m "Update soccer_schedule.ics" || echo "No changes to commit" # Avoid failure if no changes | |
git push --force origin gh-pages # Force push changes to the gh-pages branch | |