1

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) ..

Waly
  • 157
  • 1
  • 4
  • 12
  • Hey Waley — is this script bound to a Google Sheet or Google Form OR is this a standalone script? – Sourabh Choraria Mar 05 '22 at 12:51
  • The SpreadsheetApp is having more problems than usual this week i.e. custom functions loading error -> https://stackoverflow.com/q/71340032/1595451 – Rubén Mar 05 '22 at 14:06
  • Hi Sourabh, this is a .gs bound to a google sheet and set as a trigger for an onform submission – Waly Mar 05 '22 at 15:15
  • 1
    Checkout the response. One way to do this is by using `console.log(response.getContentText())` (I updated my answer) – Rubén Mar 05 '22 at 15:27

1 Answers1

4

Regarding not being stable, Google Apps Script is having problems, IMHO more than usual in the last few days.

Possible related issue reported yesterday and assigned

When having a service issue (something that only Google can fix) please search for similar issues on the apps script issue tracker and star them and if you didn't find any, post a new one.

Also keep an eye on Service Outage Log and on https://www.google.com/appsstatus/dashboard/

If you are using a Google Workspace account ask your Admin to send a support ticket.


You might also find helpful to analyse response which should be an HTTP response object. For this you might use console.log(response.getContentText())

Related

Rubén
  • 34,714
  • 9
  • 70
  • 166