Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/traffic-stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<slug>/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

Expand Down
10 changes: 10 additions & 0 deletions tools/catalog-build/test-traffic-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 7 additions & 3 deletions traffic-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading