Add a YAML parsing simulator (#1702) #321
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: IndexNow Submission | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'content/**' | |
| - 'app/**' | |
| - 'lib/games.ts' | |
| workflow_dispatch: | |
| inputs: | |
| urls: | |
| description: 'Newline-separated URLs to submit (leave empty to use sitemap)' | |
| required: false | |
| default: '' | |
| concurrency: | |
| group: indexnow | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| submit: | |
| name: Notify IndexNow | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| # A push event's github.event.before can be many commits behind | |
| # (e.g. a merge commit that brings in several PR commits at once). | |
| # fetch-depth: 2 was only enough for single-commit pushes and broke | |
| # with 'bad object' on multi-commit merges. 0 fetches full history. | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Collect changed content paths | |
| if: github.event_name == 'push' | |
| id: diff | |
| env: | |
| BEFORE_SHA: ${{ github.event.before }} | |
| AFTER_SHA: ${{ github.sha }} | |
| run: | | |
| # Initial-push case: BEFORE_SHA is all zeros, diff against the empty | |
| # tree so every current content file is submitted once. | |
| if [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ] \ | |
| || [ -z "$BEFORE_SHA" ]; then | |
| BEFORE_SHA=$(git hash-object -t tree /dev/null) | |
| fi | |
| # Defensive: if the before SHA still isn't reachable (e.g. someone | |
| # force-pushed main between the push event and this checkout), | |
| # fall back to HEAD~1 so we at least submit the latest commit. | |
| if ! git cat-file -e "$BEFORE_SHA" 2>/dev/null; then | |
| echo "Warning: BEFORE_SHA $BEFORE_SHA not found, falling back to HEAD~1" | |
| BEFORE_SHA=$(git rev-parse HEAD~1) | |
| fi | |
| git diff --name-only --diff-filter=AM "$BEFORE_SHA" "$AFTER_SHA" \ | |
| | { grep -E '^content/' || true; } > changed.txt | |
| echo "count=$(wc -l < changed.txt | tr -d ' ')" >> "$GITHUB_OUTPUT" | |
| cat changed.txt | |
| - name: Map changed paths to URLs | |
| if: github.event_name == 'push' && steps.diff.outputs.count != '0' | |
| run: | | |
| # Path -> URL mapping lives in scripts/content-path-to-url.ts so it | |
| # is unit tested against the real route shapes (news slugs, guide | |
| # parts, json-backed content, interview question tiers). | |
| bun scripts/content-path-to-url.ts < changed.txt | sort -u > urls.txt | |
| echo "URLs to submit:" | |
| cat urls.txt | |
| - name: Dry-run the IndexNow payload | |
| if: github.event_name == 'push' && steps.diff.outputs.count != '0' | |
| run: | | |
| if [ -s urls.txt ]; then | |
| cat urls.txt | bun scripts/submit-indexnow.ts --stdin --dry-run | |
| fi | |
| - name: Submit changed URLs to IndexNow | |
| if: github.event_name == 'push' && steps.diff.outputs.count != '0' | |
| run: | | |
| if [ -s urls.txt ]; then | |
| cat urls.txt | bun scripts/submit-indexnow.ts --stdin | |
| else | |
| echo "No content URLs to submit after filtering." | |
| fi | |
| - name: Submit manual URLs | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.urls != '' | |
| env: | |
| MANUAL_URLS: ${{ github.event.inputs.urls }} | |
| run: printf '%s\n' "$MANUAL_URLS" | bun scripts/submit-indexnow.ts --stdin | |
| - name: Submit full sitemap | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.urls == '' | |
| run: bun scripts/submit-indexnow.ts --sitemap |