ToolSura Blog
ArticlesAboutContact
Search

Stay in the loop

Join thousands of developers getting weekly insights into modern web development, AI tools, and productivity.

© 2026 ToolSura Blog
AboutContactPrivacy PolicyTerms of ServiceRSS

    Table of Contents

    `-json`: parseable outputExit codesExample: nightly sitemap re-index (cron)m h dom mon dow commandExample: GitHub Action`-color`: never breaks piped outputNextSources
    HomeToolsura BlogArticle

    Automating gsc-indexer in CI with -json and exit codes

    A

    Abhay khant

    Jan 1, 1970 • 2 min read

    gsc-indexer is built to run unattended. in a cron job, a GitHub Action, or any pipeline. Two features make that safe: machine-readable output and predictable exit codes.

    -json: parseable output

    -json emits a single JSON array of results at the end, with no progress noise in between (so the output stays valid JSON):

    ./gsc-indexer -creds sa.json -batch urls.txt -json
    

    Each element looks like:

    {
      "url": "https://www.toolsura.com/post/",
      "indexed": true,
      "coverage_state": "Submitted and indexed",
      "fetch_state": "SUCCESSFUL",
      "last_crawl_time": "2026-07-18T07:05:51Z"
    }
    

    Pipe it into jq or your own script to act on the results.

    Exit codes

    • Exit 0. the run finished. This includes URLs that are merely NOT INDEXED. that's a normal result, not a failure.
    • Exit non-zero. at least one URL failed (network error, HTTP error, or unparseable response).

    This makes the tool CI-friendly: a pipeline step fails only when something genuinely broke, not just because a page isn't indexed yet.

    Example: nightly sitemap re-index (cron)

    ## m h dom mon dow   command
    30 3 * * *  cd /opt/gsc-indexer && ./gsc-indexer -creds /etc/sa.json "https://www.toolsura.com/sitemap.xml" -delay 10s -q -report /var/log/gsc-report >> /var/log/gsc.log 2>&1
    

    Example: GitHub Action

    name: reindex
    on:
      schedule:
        - cron: "30 3 * * *"
    jobs:
      index:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: actions/setup-go@v5
          - run: go build -o gsc-indexer .
          - run: ./gsc-indexer -creds "$GSC_CREDS" "https://www.toolsura.com/sitemap.xml" -delay 10s -q
            env:
              GSC_CREDS: ${{ secrets.GSC_CREDS }}
    

    Store sa.json as a secret (file or env var). Never commit credentials to the repo.

    -color: never breaks piped output

    Color is auto by default (on for terminals, off when piped). You can force it with -color always or disable it with -color never. Color is decorative only. the INDEXED / NOT INDEXED text always carries the meaning.

    Next

    • Still seeing errors in automation? Troubleshooting.

    Sources

    • Google Search Console
    • URL Inspection API documentation
    • Google Search APIs overview
    • Service account OAuth (Google Identity)
    • About service accounts (Google Cloud IAM)
    • Verify site ownership
    • Property types: URL-prefix vs Domain
    • URL Inspection tool help
    • Indexing API (JobPosting/BroadcastEvent only)
    • Request indexing / inspect a URL

    Frequently Asked Questions

    developer-tools
    cli-tools
    automation
    open-source
    A

    About Abhay khant

    A passionate tech enthusiast and professional developer specializing in AI, automation, and modern web development. Sharing insights and guides to help others build better software faster.

    View full profile →

    Join the Newsletter

    Get articles like this delivered to your inbox every Thursday.

    What to read next

    Jan 1, 19709 min read

    What Is OpenCode? The 2026 Open-Source AI Coding Agent

    OpenCode topped LogRocket's July 2026 ranking with 160K+ GitHub stars and 7.5M+ monthly devs. A MIT-licensed, model-agnostic AI coding agent.

    AAbhay khant
    Jan 1, 19709 min read

    What Is the Model Context Protocol? A Plain-English Guide

    Model Context Protocol (MCP) is the open standard connecting AI to your tools and data. Learn how it works, how it differs from APIs, and why it matters.

    AAbhay khant
    Jan 1, 197010 min read

    What Are Passkeys? The Passwordless Login Standard Explained

    Passkeys are the passwordless, phishing-resistant login standard replacing passwords. Learn how they work and how they compare to 2FA.

    AAbhay khant