Google Search Console API Setup Instructions
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
- Your site must be verified in Google Search Console
- You need a Google Cloud Project
- GitHub repository with Actions enabled
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Note your Project ID
Step 2: Enable the Search Console API
- In Google Cloud Console, go to “APIs & Services” > “Library”
- Search for “Google Search Console API”
- Click on it and press “Enable”
Step 3: Create a Service Account
- Go to “APIs & Services” > “Credentials”
- Click “Create Credentials” > “Service Account”
- Fill in:
- Service account name:
search-console-submitter - Service account ID: (auto-generated)
- Description: “Submits sitemap to Search Console after deployments”
- Service account name:
- Click “Create and Continue”
- Skip the optional steps and click “Done”
Step 4: Create and Download Service Account Key
- Find your new service account in the credentials list
- Click on the service account email
- Go to the “Keys” tab
- Click “Add Key” > “Create new key”
- Choose “JSON” format
- Download the key file (keep this secure!)
Step 5: Grant Access in Search Console
- Go to Google Search Console
- Select your property (https://wevbarker.co.uk)
- Go to Settings > Users and permissions
- Click “Add user”
- Enter the service account email (found in your JSON key file, looks like:
search-console-submitter@your-project.iam.gserviceaccount.com) - Set permission to “Full” (required for sitemap submission)
- Click “Add”
Step 6: Add GitHub Secrets
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- 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
- Make a small change to your site
- Commit and push to trigger GitHub Actions
- Check the Actions tab in GitHub
- Look for the “Submit Sitemap to Google Search Console” job
- Verify it completes successfully
Monitoring
After setup, each deployment will:
- Build and deploy your site
- Automatically submit your sitemap to Google
- Log the submission status in GitHub Actions
You can verify in Search Console:
- Go to “Sitemaps” section
- You should see your sitemap listed
- 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