Skip to content

Get BigQuery Download Stats #399

Get BigQuery Download Stats

Get BigQuery Download Stats #399

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 }}