Created
March 9, 2024 05:49
-
-
Save style95/ea21517fbf81a8c86af00b2a468343fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
async function main() { | |
const USERNAME='style95'; | |
const ACCESS_TOKEN='***********'; | |
const authorizationHeader = 'Basic ' + new Buffer(USERNAME + ':' + ACCESS_TOKEN).toString('base64'); | |
const MASTER_BASE_URL = 'https://api.github.com/repos/apache/openwhisk/commits?per_page=100&sha=master'; | |
const RELEASE_BASE_URL = 'https://api.github.com/repos/apache/openwhisk/commits?per_page=1&sha=1.0.0'; | |
const data = await axios({ | |
method: 'get', | |
url: RELEASE_BASE_URL, | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': authorizationHeader, | |
'User-Agent': 'whisk' | |
} | |
}); | |
const LATEST_COMMIT_MSG = data.data[0].commit.message | |
let result = []; | |
let i = 1; | |
let skip = false; | |
while(skip === false) { | |
if(i === 10) { | |
console.log("no message found"); | |
break; | |
} | |
const res = await axios({ | |
method: 'get', | |
url: MASTER_BASE_URL + "&page=" + i, | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': authorizationHeader, | |
'User-Agent': 'whisk' | |
} | |
}); | |
for(const response of res.data) { | |
try { | |
const msg = response.commit.message; | |
const commitUrl = response.html_url; | |
let title = ''; | |
if(msg.includes('#')) { | |
title = msg.split('(')[0].trim(); | |
} else { | |
title = msg.trim(); | |
} | |
if (msg && msg.includes(LATEST_COMMIT_MSG)) { | |
console.log("Found!! " + msg); | |
skip = true; | |
result.push('Found!!'); | |
break; | |
} else { | |
const note = `- ${title} (${commitUrl}, [@${response.author.login}](${response.author.html_url}))`; | |
result.push(note); | |
} | |
} catch(e) { | |
console.log(e); | |
} | |
} | |
i++; | |
} | |
for(const r of result) { | |
console.log(r); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment