Run Data Python script #46
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: Run Python script | |
on: | |
schedule: | |
- cron: '1 */6 * * *' # runs at the first minute of every 6th hour. (12:01a, 6:01a, 12:01p, and 6:01p) | |
workflow_dispatch: # Allow manual triggering of the workflow | |
jobs: | |
run_script: | |
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.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests beautifulsoup4 | |
- name: Run Python script | |
run: python data.py | |
- name: Commit changes | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add data/latest_articles.json || git commit -m "Create latest_articles.json" | |
git commit -m "Update latest_articles.json" || echo "No changes to commit" | |
git pull origin main || echo "No remote changes to pull" | |
git push origin main | |
- name: Push changes | |
uses: ad-m/github-push-action@v0.6.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |