Skip to content

Instantly share code, notes, and snippets.

@sat0yu
Last active May 5, 2022 04:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sat0yu/0a4efbd5b7ecec53ba978e192bc097b9 to your computer and use it in GitHub Desktop.
Save sat0yu/0a4efbd5b7ecec53ba978e192bc097b9 to your computer and use it in GitHub Desktop.
CreateGithubIssueFromGoogleFormResponse
function onFormSubmit(e) {
const headers = {
outline: "Outline",
expected: "What's the expected result?",
actual: "What's the actual result?",
howToReproduce: "Steps to reproduce the issue",
details: "Additional details",
email: "Email Address",
};
const title = e.namedValues[headers.outline][0];
const body = Object.entries(headers).map(([k, v]) => `## ${k}\n${e.namedValues[v][0]}\n`).join("\n");
const token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const options = {
"method": "POST",
"contentType": "application/json",
"muteHttpExceptions": true,
"headers": {
"Authorization": "token " + token,
"Accept": "application/vnd.github.v3+json"
},
"payload": JSON.stringify({ title, body })
};
const url = "https://api.github.com/repos/REPO_OWNER/REPO_NAME/issues";
UrlFetchApp.fetch(url, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment