diff --git a/.github/workflows/traffic-stats.yml b/.github/workflows/traffic-stats.yml index 669fce0f..bc75db21 100644 --- a/.github/workflows/traffic-stats.yml +++ b/.github/workflows/traffic-stats.yml @@ -560,15 +560,17 @@ jobs: fi if [ "$AUTOMATION_PAT_CONFIGURED" != "true" ]; then - echo "::error::AUTOMATION_PAT is not configured, so the known organization policy blocks automatic PR creation. The staging branch is safe; open the weekly PR manually: $COMPARE_URL" + # Known organization policy: Actions cannot open pull requests. The data is staged, so + # this is a reminder, not a failure; a failure here would stay red every Friday. + echo "::warning::Weekly traffic data is staged on $PUBLISH_BRANCH. Actions cannot open pull requests here (organization policy), so open the weekly PR manually: $COMPARE_URL" { - echo "### ⚠️ Weekly traffic data needs a manual PR" + echo "### Weekly traffic data is ready for a manual PR" echo "" echo "Daily collection remains safely accumulated on \`$STAGING_BRANCH\`." echo "" echo "**Open the review-required PR:** $COMPARE_URL" } >> "$GITHUB_STEP_SUMMARY" - exit 1 + exit 0 fi if ! gh pr create --title "$TITLE" --body "$BODY" \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 58b12cdc..f1c0827d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ This file captures only selected high-level milestones. * Archived the prompt samples and removed a 41 MB archived demo video. * Added a **Download** button to resource pages and the landing detail view for resources that are one self-contained file: interactive guides and tools (saved as a single HTML file), single-file scripts, PowerPoint decks, Power BI reports, and the Technical Advisory PDF. The button opens a short download page (`r//download/`) that saves the file and records the download. Loads of that page are counted per resource as `downloads` in `resource-stats.json`, kept separate from views, and logged as a `resource_download` event in Clarity. An optional `download` front matter field picks the file explicitly; see `docs/CATALOG-METADATA.md`. * The daily **Collect Traffic Data** workflow no longer collects GitHub repository traffic (views, clones, referrers), which needs a token that expires every few days under organization policy. It skips that step with a notice and keeps collecting Clarity page analytics and discussion votes. Set the repository variable `COLLECT_GITHUB_TRAFFIC` to `true` and replace `TRAFFIC_TOKEN` to resume. +* The Friday run of **Collect Traffic Data** no longer fails when it cannot open the weekly traffic pull request because of the organization policy. It stays green and adds a warning and a run summary with the compare link to open it by hand. A configured token that still cannot create the pull request fails the run, as before. ### April 20, 2018 diff --git a/tools/catalog-build/test-traffic-workflow.js b/tools/catalog-build/test-traffic-workflow.js index 1ccf10f4..23e5fc55 100644 --- a/tools/catalog-build/test-traffic-workflow.js +++ b/tools/catalog-build/test-traffic-workflow.js @@ -144,6 +144,16 @@ assert(weeklyPr.run.includes('AUTOMATION_PAT_CONFIGURED') && weeklyPr.run.includes('COMPARE_URL') && !weeklyPr.run.includes('gh pr merge'), 'Blocked PR creation must provide a manual compare URL and remain review-required.'); +const notConfigured = weeklyPr.run.match(/if \[ "\$AUTOMATION_PAT_CONFIGURED" != "true" \]; then([\s\S]*?)\nfi\n/)?.[1] ?? ''; +assert(notConfigured.includes('::warning::') && notConfigured.includes('$COMPARE_URL') && + notConfigured.includes('GITHUB_STEP_SUMMARY') && notConfigured.includes('exit 0') && + !notConfigured.includes('::error::') && !notConfigured.includes('exit 1'), + 'The known organization policy (no AUTOMATION_PAT) must warn with the compare link, not fail the Friday run.'); +const createFailure = weeklyPr.run.slice(weeklyPr.run.indexOf('gh pr create')); +assert(createFailure.includes('::error::') && createFailure.includes('exit 1') && + weeklySteps.some(step => step.name === 'Fail when weekly PR preparation was blocked' && + step.if.includes("steps.weekly-pr.outcome == 'failure'")), + 'A configured token that still cannot create the weekly PR is unexpected and must fail the run.'); const catalogStats = catalogWorkflow.jobs.publish.steps.find( step => typeof step.run === 'string' && step.run.includes('build:stats') diff --git a/traffic-data/README.md b/traffic-data/README.md index 9a5395b7..e463e7db 100644 --- a/traffic-data/README.md +++ b/traffic-data/README.md @@ -12,9 +12,13 @@ Data is collected daily at 06:00 UTC via GitHub Actions. Each Friday at 08:00 `America/Chicago` (including daylight saving time), the workflow updates one review-required pull request from the Friday-only `automation/traffic-stats-weekly` branch to `master`. Daily pushes to the staging branch therefore do not change the -open weekly review. If the optional `AUTOMATION_PAT` is not configured or cannot -create pull requests, the workflow prints a manual compare URL; daily collection -continues safely on the staging branch. +open weekly review. If the optional `AUTOMATION_PAT` is not configured, which is the +case under the organization's policy against Actions opening pull requests, the Friday +run stays green and adds a warning and a run summary with a manual compare URL +(`/compare/master...automation/traffic-stats-weekly`). Open that pull request, check that +it changes only `resource-stats.json` and `traffic-data/clarity-views.json`, and merge +it. If a configured token cannot create the pull request, the run fails instead. Daily +collection continues safely on the staging branch either way. ## GitHub repository traffic is paused