run main.py #86
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 main.py | |
on: | |
schedule: | |
- cron: '0 5 * * *' # At 05:00 on daily | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repo content | |
uses: actions/checkout@v4 # checkout the repository content | |
with: | |
token: ${{ secrets.BOT_ACCESS_TOKEN }} | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11.4' # install the python version needed | |
cache: 'pip' # caching pip dependencies | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: execute py script # run main.py | |
env: | |
DB: ${{ secrets.DB }} | |
HOST: ${{ secrets.HOST }} | |
PORT: ${{ secrets.PORT }} | |
API_USER: ${{ secrets.API_USER }} | |
API_PASSWORD: ${{ secrets.API_PASSWORD }} | |
run: python main.py | |
- name: Commit and push if the database changed | |
if: always() | |
run: |- | |
git config user.name github-actions | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git add backup.csv | |
timestamp=$(date -u) | |
git commit -m "Latest Database: ${timestamp}" || exit 0 | |
git push | |
- name: Send mails | |
if: always() | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
username: ${{ secrets.MAIL_USERNAME }} | |
password: ${{ secrets.MAIL_PASSWORD }} | |
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }} | |
body: ${{ github.job }} job in workflow ${{ github.workflow }} of ${{ github.repository }} has great ${{ job.status }}! | |
to: aholme27@vols.utk.edu, tdykes2@vols.utk.edu, asajjad@vols.utk.edu, lmcpherr@vols.utk.edu | |
from: GitHub Actions |