weekly-digest.yml
Mondays: runs redline metrics digest and posts the card to Teams. Lives in the redline-metrics repo.
Posts a Monday stakeholder digest to Teams as an Adaptive Card: open and stale PR counts, seed recall, a dashboard link.
| Runs in | The redline-metrics repository — not this one. |
|---|---|
| Runs on | Mondays at 07:00 UTC, and workflow_dispatch. |
| Credential | REDLINE_ORG_READ_TOKEN, read-only across the org, and TEAMS_WEBHOOK_URL to post the card. |
| Leaves behind | One card in Teams, and the payload attached to the run summary either way. |
What a run does
- Counts open and stale (not updated for 7 days) non-draft org PRs through the GitHub search API.
- Runs npx --yes [email protected] metrics digest with those counts, data/seed-scores.jsonl and the dashboard URL, writing digest.json.
- POSTs digest.json to TEAMS_WEBHOOK_URL. If the secret is unset the step fails rather than skipping delivery quietly.
Setting it up
Copy the file into redline-metrics and set REDLINE_ORG_READ_TOKEN and TEAMS_WEBHOOK_URL there, plus the REDLINE_DASHBOARD_URL variable for the link. The webhook is a Power Automate "When a Teams webhook request is received" flow.
Changing it
Edit workflows/weekly-digest.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.
Related
- redline metrics
- Who runs what — every credential, side by side.
- All workflows
The full file
# Lives in the redline-metrics repo. Monday-morning stakeholder digest.
#
# TEAMS_WEBHOOK_URL must point at a Power Automate "When a Teams webhook request is
# received" flow. The old Office 365 connector webhooks (the `{"text": "..."}` shape)
# were retired by Microsoft and silently stop delivering.
name: Redline Weekly Digest
on:
schedule:
- cron: '0 7 * * 1'
workflow_dispatch:
permissions:
contents: read
jobs:
digest:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
- name: Count open and stale PRs
id: prs
env:
GH_TOKEN: ${{ secrets.REDLINE_ORG_READ_TOKEN }}
ORG: ${{ github.repository_owner }}
run: |
set -euo pipefail
cutoff=$(date -u -d '7 days ago' +%Y-%m-%d)
# gh search caps at 1000 results; --json + jq length would silently truncate.
# total_count from the REST search endpoint is exact.
count() {
gh api -X GET search/issues -f q="$1" -f per_page=1 --jq '.total_count'
}
open_prs=$(count "org:$ORG is:pr is:open draft:false")
stale_prs=$(count "org:$ORG is:pr is:open draft:false updated:<$cutoff")
echo "open=$open_prs" >> "$GITHUB_OUTPUT"
echo "stale=$stale_prs" >> "$GITHUB_OUTPUT"
- name: Build Adaptive Card
run: |
npx --yes "[email protected]" metrics digest \
--org "${{ github.repository_owner }}" \
--days 7 \
--open-prs "${{ steps.prs.outputs.open }}" \
--stale-prs "${{ steps.prs.outputs.stale }}" \
--seed-scores data/seed-scores.jsonl \
--dashboard-url "${{ vars.REDLINE_DASHBOARD_URL }}" \
--out digest.json
- name: Post to Teams
env:
WEBHOOK: ${{ secrets.TEAMS_WEBHOOK_URL }}
run: |
set -euo pipefail
if [[ -z "${WEBHOOK:-}" ]]; then
echo "::error::TEAMS_WEBHOOK_URL is not set — digest built but not delivered."
exit 1
fi
curl -sS --fail-with-body -X POST \
-H 'Content-Type: application/json' \
--data @digest.json "$WEBHOOK"
- name: Attach digest to the run
if: always()
run: |
{
echo '### Digest payload'
echo '```json'
cat digest.json 2>/dev/null || echo '{}'
echo '```'
} >> "$GITHUB_STEP_SUMMARY"