diff --git a/.github/workflows/build-catalog.yml b/.github/workflows/build-catalog.yml index 51f1b872..c9b03cc3 100644 --- a/.github/workflows/build-catalog.yml +++ b/.github/workflows/build-catalog.yml @@ -27,6 +27,7 @@ on: permissions: contents: write + discussions: read jobs: validate: @@ -62,14 +63,22 @@ jobs: working-directory: tools/catalog-build - run: npm run build working-directory: tools/catalog-build + - run: npm run build:stats + working-directory: tools/catalog-build + env: + CLARITY_API_TOKEN: ${{ secrets.CLARITY_API_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Commit generated catalog run: | - if git diff --quiet -- catalog.json; then - echo "Catalog is already current." + git add catalog.json resource-stats.json traffic-data/clarity-views.json resource-discussions.json + if [ -f design-concepts/resource-stats.json ]; then + git add design-concepts/resource-stats.json + fi + if git diff --cached --quiet; then + echo "Catalog and resource stats are already current." exit 0 fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add catalog.json git commit -m "chore: rebuild catalog [skip ci]" git push diff --git a/.github/workflows/traffic-stats.yml b/.github/workflows/traffic-stats.yml index e9e2d724..609a9454 100644 --- a/.github/workflows/traffic-stats.yml +++ b/.github/workflows/traffic-stats.yml @@ -8,6 +8,7 @@ on: permissions: contents: write + discussions: read pull-requests: write concurrency: @@ -24,6 +25,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: tools/catalog-build/package-lock.json + + - name: Install catalog build dependencies + run: npm ci + working-directory: tools/catalog-build + - name: Collect and persist traffic data env: GH_TOKEN: ${{ secrets.TRAFFIC_TOKEN }} @@ -176,13 +188,22 @@ jobs: echo "✅ Saved $DATA_DIR/$DATE.json" + - name: Build resource stats + env: + CLARITY_API_TOKEN: ${{ secrets.CLARITY_API_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: node tools/catalog-build/build-stats.js + - name: Commit and open PR env: GH_TOKEN: ${{ secrets.TRAFFIC_TOKEN }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add traffic-data/ + git add traffic-data/ resource-stats.json resource-discussions.json + if [ -f design-concepts/resource-stats.json ]; then + git add design-concepts/resource-stats.json + fi if git diff --cached --quiet; then echo "No changes to commit" exit 0 diff --git a/index.html b/index.html index a97366b4..6914c72c 100644 --- a/index.html +++ b/index.html @@ -1449,6 +1449,11 @@