Skip to content

Update Download Stats #6

Update Download Stats

Update Download Stats #6

Workflow file for this run

name: Update Download Stats
# Maintains a cumulative installer-download counter in R2 and writes a
# shields.io endpoint badge (stats/downloads.json). R2 analytics only retains
# ~32 days, so the running total is accumulated daily from fully-elapsed days.
# The Cloudflare Analytics API token lives only in Secrets and never leaves the
# runner; the published badge JSON contains no credentials.
on:
workflow_dispatch:
schedule:
- cron: "37 2 * * *" # daily at 02:37 UTC
permissions:
contents: read
concurrency:
group: codex-app-mirror-stats
cancel-in-progress: false
env:
R2_BUCKET_NAME: codex-app-mirror
jobs:
stats:
name: Update cumulative download badge
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Ensure AWS CLI
shell: bash
run: |
set -euo pipefail
if ! command -v aws >/dev/null 2>&1; then
python3 -m pip install --user awscli
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
fi
- name: Update stats and badge
env:
CF_ANALYTICS_API_TOKEN: ${{ secrets.CF_ANALYTICS_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
R2_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
run: python3 scripts/update-download-stats.py