Google Search Console API Setup Instructions

Overview

This guide will help you set up automated sitemap submission to Google Search Console after each GitHub Pages deployment.

Prerequisites

  1. Your site must be verified in Google Search Console
  2. You need a Google Cloud Project
  3. GitHub repository with Actions enabled

Step 1: Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Note your Project ID

Step 2: Enable the Search Console API

  1. In Google Cloud Console, go to “APIs & Services” > “Library”
  2. Search for “Google Search Console API”
  3. Click on it and press “Enable”

Step 3: Create a Service Account

  1. Go to “APIs & Services” > “Credentials”
  2. Click “Create Credentials” > “Service Account”
  3. Fill in:
    • Service account name: search-console-submitter
    • Service account ID: (auto-generated)
    • Description: “Submits sitemap to Search Console after deployments”
  4. Click “Create and Continue”
  5. Skip the optional steps and click “Done”

Step 4: Create and Download Service Account Key

  1. Find your new service account in the credentials list
  2. Click on the service account email
  3. Go to the “Keys” tab
  4. Click “Add Key” > “Create new key”
  5. Choose “JSON” format
  6. Download the key file (keep this secure!)

Step 5: Grant Access in Search Console

  1. Go to Google Search Console
  2. Select your property (https://wevbarker.co.uk)
  3. Go to Settings > Users and permissions
  4. Click “Add user”
  5. Enter the service account email (found in your JSON key file, looks like: search-console-submitter@your-project.iam.gserviceaccount.com)
  6. Set permission to “Full” (required for sitemap submission)
  7. Click “Add”

Step 6: Add GitHub Secrets

  1. Go to your GitHub repository
  2. Navigate to Settings > Secrets and variables > Actions
  3. Add two new repository secrets:

Secret 1: SEARCH_CONSOLE_SERVICE_ACCOUNT_JSON

  • Name: SEARCH_CONSOLE_SERVICE_ACCOUNT_JSON
  • Value: The entire contents of your downloaded JSON key file
  • Example:
    {
    "type": "service_account",
    "project_id": "your-project-id",
    "private_key_id": "...",
    "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
    "client_email": "search-console-submitter@your-project.iam.gserviceaccount.com",
    "client_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "..."
    }
    

Secret 2: SITE_URL

  • Name: SITE_URL
  • Value: https://wevbarker.co.uk/
  • Note: Must match exactly how it’s verified in Search Console (with or without trailing slash)

Step 7: Test the Setup

  1. Make a small change to your site
  2. Commit and push to trigger GitHub Actions
  3. Check the Actions tab in GitHub
  4. Look for the “Submit Sitemap to Google Search Console” job
  5. Verify it completes successfully

Monitoring

After setup, each deployment will:

  1. Build and deploy your site
  2. Automatically submit your sitemap to Google
  3. Log the submission status in GitHub Actions

You can verify in Search Console:

  1. Go to “Sitemaps” section
  2. You should see your sitemap listed
  3. Check “Last submitted” date updates after deployments

Troubleshooting

“Site not verified” error

  • Ensure the service account email has Full access in Search Console
  • Verify the SITE_URL matches exactly (including https:// and trailing slash)

“Permission denied” error

  • Check the service account has “Full” permission, not just “Restricted”
  • Ensure the Search Console API is enabled in your Google Cloud project

“Invalid credentials” error

  • Verify the entire JSON content is in the GitHub secret
  • Check for any copy/paste errors or missing characters

Security Notes

  • Never commit the service account JSON key to your repository
  • The JSON key in GitHub Secrets is encrypted and safe
  • Rotate keys periodically for security
  • Only grant the minimum required permissions

Next Steps

Once working, this automation ensures Google always has your latest sitemap after each deployment. Future enhancements could include:

  • Requesting indexing for specific new pages
  • Monitoring index coverage
  • Performance tracking integration