Get BigQuery Download Stats #394
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: Get BigQuery Download Stats | |
| on: | |
| schedule: | |
| - cron: '0 7 * * *' # Runs at 7 AM UTC, which is 2 AM EST | |
| workflow_dispatch: # Allows manual trigger | |
| jobs: | |
| query: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Needed to push to existing branches | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install google-cloud-bigquery pandas | |
| - name: Run BigQuery query | |
| env: | |
| GOOGLE_APPLICATION_CREDENTIALS_CONTENT: ${{ secrets.GCP_CREDENTIALS }} | |
| run: python misc/bigquery_download_stats.py | |
| - name: Configure Git | |
| run: | | |
| git config user.email "action@github.com" | |
| git config user.name "GitHub Actions" | |
| - name: Commit and force push CSV to 'download_stats' branch | |
| run: | | |
| git fetch origin download_stats || true | |
| git checkout -B download_stats origin/download_stats || git checkout -b download_stats | |
| git add misc/bigquery_download_stats.csv | |
| git commit -m "Update BigQuery download stats CSV" || echo "Nothing to commit" | |
| git push origin download_stats --force | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |