Last active
May 5, 2022 04:21
-
-
Save sat0yu/0a4efbd5b7ecec53ba978e192bc097b9 to your computer and use it in GitHub Desktop.
CreateGithubIssueFromGoogleFormResponse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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