Fetch Video Data and Update Repository #42
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: Fetch Video Data and Update Repository | |
on: | |
schedule: | |
# Runs the workflow every 12 hours (Cron format) | |
- cron: '0 */12 * * *' # At the start of every 12th hour | |
push: | |
branches: | |
- main # Run when code is pushed to the main branch | |
jobs: | |
fetch_and_update: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
# Step 4: Run Python script to fetch video data | |
- name: Fetch video data | |
run: python fetch_videos.py | |
# Step 5: Commit and push changes | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GitHub's built-in token | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Actions Bot" | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Update video data" | |
git push origin main | |
# Step 6: Clean up and confirm the updates | |
- name: Clean up and confirm updates | |
run: | | |
echo "Video data updated successfully!" |