Skip to content

Collect Play Console stats #50

Collect Play Console stats

Collect Play Console stats #50

Workflow file for this run

name: Collect Play Console stats
on:
schedule:
- cron: '0 8 * * *' # daily; Play vitals/installs update once a day
workflow_dispatch:
jobs:
collect:
runs-on: ubuntu-latest
# Skip entirely unless the service-account secret is configured.
env:
HAS_SA: ${{ secrets.PLAY_SA_JSON != '' }}
steps:
- uses: actions/checkout@v5
- name: Install uv
if: env.HAS_SA == 'true'
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Install dependencies
if: env.HAS_SA == 'true'
run: uv sync
- name: Collect vitals + install base
if: env.HAS_SA == 'true'
env:
PLAY_SA_JSON: ${{ secrets.PLAY_SA_JSON }}
PLAY_BUCKET: ${{ secrets.PLAY_BUCKET }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/play-sa.json
run: |
printf '%s' "$PLAY_SA_JSON" > "$GOOGLE_APPLICATION_CREDENTIALS"
uv run vitals.py crash-rate --days 30 --update data/android-crash-rate.csv
uv run vitals.py anr-rate --days 30 --update data/android-anr-rate.csv
# installed.csv = Active Device Installs; android-ratings.csv = store
# rating over time — both from the bulk reports (#17).
if [ -n "$PLAY_BUCKET" ]; then
uv run android_installs.py --bucket "$PLAY_BUCKET" update
uv run android_ratings.py --bucket "$PLAY_BUCKET"
fi
# Track/rollout state (Publisher API). Needs a release permission the
# vitals-only SA may not have, so a denial (exit 3) must not fail the
# whole collection -- but it must stay visible rather than silently
# skipping, which is how the vitals feed stalled unnoticed for a week.
uv run play_tracks.py --update data/android-tracks.csv \
|| echo "::warning::play_tracks.py failed (exit $?) - track state not updated"
rm -f "$GOOGLE_APPLICATION_CREDENTIALS"
- name: Commit
if: env.HAS_SA == 'true'
run: |
git config --local user.email "noreply@github.com"
git config --local user.name "GitHub Action"
git add data/android-crash-rate.csv data/android-anr-rate.csv data/android/installed.csv data/android-ratings.csv
# android-tracks.csv may not exist yet if play_tracks.py lacked permission
[ -f data/android-tracks.csv ] && git add data/android-tracks.csv || true
git diff --cached --quiet || git commit -m "chore: update Play Console stats"
- name: Push changes
if: env.HAS_SA == 'true'
uses: ad-m/github-push-action@fe38f0a751bf9149f0270cc1fe20bf9156854365
with:
github_token: ${{ secrets.GITHUB_TOKEN }}