Skip to content

Commit

Permalink
Add script to check incoming branch for 404s per #1726
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones-plip committed Dec 10, 2024
1 parent 9f9ba5a commit 89f1fb5
Show file tree
Hide file tree
Showing 3 changed files with 468 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/check-for-404s.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

import Sitemapper from 'sitemapper';
import http from 'http';


// https://github.com/seantomburke/sitemapper
const sitemapper = new Sitemapper();
const testUrl = 'http://localhost:1313'
sitemapper.timeout = 1000;

sitemapper
.fetch('https://docs.communityhealthtoolkit.org/sitemap.xml')
.then(({ url, sites }) => {
// console.log(`url:${url}`, 'sites:', sites);
sites.forEach((docUrl) => {
docUrl = testUrl + docUrl.replace(
'https://docs.communityhealthtoolkit.org',
''
);
http.get(docUrl, res => {
let data = [];
const headerDate = res.headers && res.headers.date ? res.headers.date : 'no response date';
console.log('URL:', docUrl, 'Status Code:', res.statusCode);
}).on('error', err => {
console.log('Error: ', err.message);
});
});
console.log(`url:${url}`);

})
.catch((error) => console.log(error));



Loading

0 comments on commit 89f1fb5

Please sign in to comment.