Skip to content

Instantly share code, notes, and snippets.

@style95
Created March 9, 2024 05:49
Show Gist options
  • Save style95/ea21517fbf81a8c86af00b2a468343fa to your computer and use it in GitHub Desktop.
Save style95/ea21517fbf81a8c86af00b2a468343fa to your computer and use it in GitHub Desktop.
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