redline-collect.yml

Nightly: runs redline metrics collect and commits the telemetry. Lives in the redline-metrics repo.

Pulls review outcomes for merged pull requests across the org and commits them as monthly JSONL.

Runs inThe redline-metrics repository — not this one.
Runs onDaily at 05:00 UTC, and workflow_dispatch with a days input (default 8).
CredentialREDLINE_ORG_READ_TOKEN, read-only across the org. The commit goes to redline-metrics under the run's own token.
Leaves behindA commit under data/ in redline-metrics, or nothing when no telemetry changed.

What a run does

  1. Runs npx --yes [email protected] metrics collect --org <owner> --days <days> --out data, with REDLINE_ORG_READ_TOKEN as GH_TOKEN.
  2. If anything under data/ changed, commits it as "data: telemetry through <date>", rebasing before the push so a concurrent commit does not collide.

Setting it up

Copy the file into redline-metrics as .github/workflows/redline-collect.yml and set the REDLINE_ORG_READ_TOKEN secret there.

Changing it

Edit workflows/redline-collect.yml in this repository, then follow Changing a workflow. The copy in redline-metrics does not update itself: copy the file across again after the change merges.

The full file

workflows/redline-collect.yml · 62 lines · 1.9 KB
# Lives in the redline-metrics repo. Pulls review outcomes for merged PRs across the org
# and commits them as monthly JSONL.
#
# Replaces the old per-repo telemetry workflow: no Redline secret is stored in any
# product repo, so onboarding a repo grants Redline no write access to anything.
name: Redline Collect

on:
  schedule:
    - cron: '0 5 * * *'
  workflow_dispatch:
    inputs:
      days:
        description: Look-back window in days
        type: string
        default: '8'

permissions:
  contents: write

concurrency:
  group: redline-collect
  cancel-in-progress: false

jobs:
  collect:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 22

      - name: Collect telemetry
        env:
          # Read-only: repo metadata + pull requests across the org. No write scope.
          # The token travels as an environment variable rather than a flag: a
          # command line is visible in the process table.
          GH_TOKEN: ${{ secrets.REDLINE_ORG_READ_TOKEN }}
        run: |
          npx --yes "[email protected]" metrics collect \
            --org "${{ github.repository_owner }}" \
            --days "${{ inputs.days || '8' }}" \
            --out data

      - name: Commit
        run: |
          set -euo pipefail
          if git diff --quiet -- data; then
            echo "no telemetry changes" >> "$GITHUB_STEP_SUMMARY"
            exit 0
          fi
          git config user.name  "redline-bot"
          git config user.email "[email protected]"
          git add data
          git commit -m "data: telemetry through $(date -u +%Y-%m-%d)"
          # Another run (or a digest commit) may have landed since checkout.
          git pull --rebase origin "${GITHUB_REF_NAME}"
          git push origin "HEAD:${GITHUB_REF_NAME}"
          git diff --stat HEAD~1 -- data >> "$GITHUB_STEP_SUMMARY"