I'm testing a simple script to create Google App Script that triggers opening and updating GitHub issues upon submission of Google sheets,
If I test a working simple trigger like this one:
var ghToken = "my_GitHub_Token";
function onFormSubmit(e) {
var title = "This is a static title";
var body = "this is the body";
var payload = {
"title": title,
"body": body
};
var options = {
"method": "POST",
"headers": {
"authorization": "token "+ghToken
},
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch("https://api.github.com/repos/Example/Example/issues?access_token="+ghToken, options);
}
if I excute that trigger it works - BUT not stable each time, and there are missing responses in the post request for creating new issues,
it is even much worse if I try to pass responses from the Google form to the github fetch by any get request
so this trigger for example :
var ghToken = "my_GitHub_Token";
function onFormSubmit(e) {
var title = e.values[2];
var body = "this is the body";
var payload = {
"title": title,
"body": body
};
var options = {
"method": "POST",
"headers": {
"authorization": "token "+ghToken
},
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch("https://api.github.com/repos/Example/Example/issues?access_token="+ghToken, options);
}
The above trigger will not pass any responses in the issue, will even not post any issue at GitHub (unlike the first trigger with the static title). It fails to pass anything, and you can't find any faliures in the logs of that trigger to track where does it stop!
The Google App Script documentation seems to describe smooth operations, : https://developers.google.com/apps-script/guides/triggers/events#form-submit_1 - But it seems to be not that efficient in automation, and even a working useless trigger passing static titles and plain text seems not to succeed in the methods defined for the trigger each time.
I might be doing something wrong, but non of the available scripts online for the same purpose seem to work either , for example:
here: https://gist.github.com/bmcbride/62600e48274961819084 There: https://medium.com/@01010111/using-google-forms-to-submit-github-issues-efdb5f876b
And almost everywhere - none of them are functioning as described, I can't be copying and pasting wrong- since my control trigger (the first one) is worrking fine! and again not stable for each submission (it should open a new issue onFormSubmission, but it doesnt do that each time - some records on the sheet responses will miss an issue on GitHub) ..