Skip to content

Commit

Permalink
Create publish.js
Browse files Browse the repository at this point in the history
  • Loading branch information
toteph42 authored Mar 27, 2024
1 parent 944a793 commit a2102e1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/publish_sitemap/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { google } = require('googleapis');
const { JWT } = require('google-auth-library');
const searchconsole = google.searchconsole('v1');

const keys = JSON.parse(Buffer.from(process.env.GOOGLE_SEARCH_CONSOLE_JSON_KEY, 'base64').toString('utf-8'));
const client = new JWT({
email: keys.client_email,
key: keys.private_key,
scopes: ['https://www.googleapis.com/auth/webmasters', 'https://www.googleapis.com/auth/webmasters.readonly'],
});

google.options({ auth: client });

(async () => {
try {
await searchconsole.sitemaps.submit({
// UPDATE THIS TO YOUR OWN SITEMAP
feedpath: 'https://stateful.com/sitemap.xml',
siteUrl: 'https://stateful.com/',
});

} catch (e) {
console.log(e);
}

})();

0 comments on commit a2102e1

Please sign in to comment.