Run Data2 Python script #2498
This file contains hidden or 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 Data2 Python script | |
| on: | |
| schedule: | |
| - cron: '20 6 * * *' # 11:50 AM IST (06:20 AM UTC) | |
| - cron: '00 10 * * *' # 03:30 PM IST (10:00 AM UTC) | |
| - cron: '30 13 * * *' # 07:00 PM IST (01:30 PM UTC) | |
| - cron: '00 16 * * *' # 09:30 PM IST (04:00 PM UTC) | |
| 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 lxml | |
| - name: Load secrets | |
| run: echo "SIURL=${{ secrets.SIURL }}" >> $GITHUB_ENV | |
| - name: Run Python script | |
| run: python data2.py | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Actions" | |
| # Stage the changes | |
| git add data/data2.json | |
| # Check if there are changes to commit | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update data2.json" | |
| git push origin main | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Push changes | |
| uses: ad-m/[email protected] | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: main |