Skip to content

Commit

Permalink
Update sitemaps.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Nov 18, 2023
1 parent 12ec0f9 commit 5035a03
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/sitemaps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ jobs:
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
def submit_sitemap(site_url, sitemap_url, credentials_json):
credentials = ServiceAccountCredentials.from_json_keyfile_dict(json.loads(credentials_json), ['https://www.googleapis.com/auth/webmasters'])
webmasters_service = build('webmasters', 'v3', credentials=credentials)
webmasters_service.sitemaps().submit(siteUrl=site_url, feedpath=sitemap_url).execute()
print(f'Submitted {sitemap_url}')
try:
credentials = ServiceAccountCredentials.from_json_keyfile_dict(json.loads(credentials_json), ['https://www.googleapis.com/auth/webmasters'])
webmasters_service = build('webmasters', 'v3', credentials=credentials)
webmasters_service.sitemaps().submit(siteUrl=site_url, feedpath=sitemap_url).execute()
print(f'Submitted {sitemap_url} ✅')
except Exception as e:
print(f'ERROR ❌: {sitemap_url} failed to submit {e}')
credentials_json = os.environ['CREDENTIALS_JSON']
# Submit sitemap for the main site
submit_sitemap('https://docs.ultralytics.com', 'https://docs.ultralytics.com/sitemap.xml', credentials_json)
Expand Down

0 comments on commit 5035a03

Please sign in to comment.