name: Ping Search Engines

# Automatically notify search engines when content changes
on:
  push:
    branches:
      - main
    paths:
      - 'src/content/blog/**'
      - 'src/content/portfolio/**'
      - 'src/pages/**'
  workflow_dispatch: # Allow manual trigger

jobs:
  ping-sitemap:
    name: Notify Search Engines
    runs-on: ubuntu-latest

    steps:
      - name: Ping Google
        run: |
          echo "Pinging Google with sitemap..."
          HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://www.google.com/ping?sitemap=https://workroot.in/sitemap.xml")
          echo "Google response: $HTTP_CODE"
          if [ "$HTTP_CODE" = "200" ]; then
            echo "✅ Google pinged successfully"
          else
            echo "⚠️ Google ping returned HTTP $HTTP_CODE"
          fi

      - name: Ping Bing
        run: |
          echo "Pinging Bing with sitemap..."
          HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://www.bing.com/ping?sitemap=https://workroot.in/sitemap.xml")
          echo "Bing response: $HTTP_CODE"
          if [ "$HTTP_CODE" = "200" ]; then
            echo "✅ Bing pinged successfully"
          else
            echo "⚠️ Bing ping returned HTTP $HTTP_CODE"
          fi

      - name: Summary
        run: |
          echo "✨ Sitemap ping workflow complete"
          echo "Search engines notified of content updates"
          echo "Check Search Console and Bing Webmaster Tools for indexing status"
