Execute On Schedule #12176
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: Execute On Schedule | |
on: | |
schedule: | |
- cron: '15 * * * *' # Executes at 15 minutes past the hour. | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository Contents | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install Python Packages Requirements | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements | |
- name: Execute Python Script | |
run: python main.py | |
- name: Commit Files | |
run: | | |
git config --local user.email "seyyedsoroushmirzaei@protonmail.com" | |
git config --local user.name "Soroush Mirzaei" | |
git add -A | |
git diff-index --quiet HEAD || (git commit -a -m "Updated $(TZ='Asia/Tehran' date '+%Y-%m-%d %H:%M %Z')" --allow-empty) | |
- name: Push Changes | |
uses: ad-m/github-push-action@v0.6.0 | |
with: | |
github_token: ${{ secrets.TG_CNFG_CLLCT }} | |
branch: main | |
- name: Clean Up Files | |
run: | | |
git checkout --orphan latest_branch | |
git rm -r -f __pycache__ | |
git config --local user.email "seyyedsoroushmirzaei@protonmail.com" | |
git config --local user.name "Soroush Mirzaei" | |
git add -A | |
git commit -am "Updated $(TZ='Asia/Tehran' date '+%Y-%m-%d %H:%M %Z')" | |
git branch -D main | |
git branch -m main | |
git push -f origin main | |
- name: Push Changes | |
uses: ad-m/github-push-action@v0.6.0 | |
with: | |
github_token: ${{ secrets.TG_CNFG_CLLCT }} | |
branch: main |