Update Data #124
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: Update Data | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| push: | |
| branches: [ main ] | |
| schedule: | |
| - cron: '0 12 * * *' # 6 AM Chicago (CST), 7 AM during CDT | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| create: | |
| if: ${{ github.event_name == 'workflow_dispatch' | |
| || github.event_name == 'schedule' | |
| || contains(github.event.head_commit.message, 'data update') }} | |
| name: create dataset | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| pushed: ${{ steps.commit.outputs.pushed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: clean dir | |
| run: | | |
| rm -rf data | |
| mkdir data | |
| - name: Run script | |
| run: | | |
| python scripts/create_dataset.py | |
| ls data | |
| - name: check if successful, then commit | |
| id: commit | |
| run: | | |
| if [ -f done ]; then | |
| echo "generated dataset successfully" | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git add -A data/ | |
| if git diff --cached --quiet; then | |
| echo "no data changes to commit" | |
| echo "pushed=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "Update data" | |
| git push | |
| echo "pushed=true" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "failed to generate dataset" | |
| echo "pushed=false" >> $GITHUB_OUTPUT | |
| fi | |
| deploy: | |
| needs: create | |
| if: needs.create.outputs.pushed == 'true' | |
| uses: ./.github/workflows/deploy.yml |