Update data #5
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: Update data | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
poetry install | |
poetry run python scripts/initialize_db.py # set up database | |
- name: Fetch data | |
run: | | |
CURRENT_DATE=$(date -u +"%Y-%m-%d") | |
LAST_WEEK=$(date -u -d "7 days ago" +"%Y-%m-%d") | |
poetry run python src/ai_agent_statistics/__main__.py \ | |
--token=${{ secrets.GITHUB_TOKEN }} \ | |
--start-date=${LAST_WEEK} \ | |
--end-date=${CURRENT_DATE} | |
- name: Export result data | |
run: | | |
poetry run python scripts/export_db.py | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'kaakaa' | |
git config --global user.email '[email protected]' | |
git add webapp/public/assets/* | |
git commit -m "Update data: $(date -u +'%Y-%m-%d')" || echo "No changes to commit" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |