Skip to content

Instantly share code, notes, and snippets.

@sat0yu
Last active Mar 25, 2021
Embed
What would you like to do?
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