Last active
June 22, 2023 08:57
-
-
Save ernestoguimaraes/34cbe0d7021f5f2afd71126153f3ab79 to your computer and use it in GitHub Desktop.
GitHub Issues Template Form Extractor
This file contains hidden or 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
//Here is the Code Snippet to extract fields in a Issue Template on GITHUB when using type INPUT and DROPDOWN. | |
//The end result is a MAP object wher you can get it from other Jobs and use in your code like: | |
//When using the github-script action (https://github.com/actions/github-script) , it enables JavaScript language | |
//for scripting bu you can adapt to any language | |
//usages: let value = map["### LabelField01"] | |
let conteudo = context.payload.issue.body; | |
console.log (conteudo); | |
let conteudoNoBlankLines= conteudo.replace(/(^[ \t]*\n)/gm, ""); | |
let Search ="### LabelField01,### LabelField02,### LabelField03\,### LabelField04"; | |
let arraySearch = Search.split(","); | |
const map= new Map(); | |
arraySearch.forEach((element, index) => { | |
let search = element; | |
let fromInd = conteudoNoBlankLines.indexOf(search); | |
let serachStart = fromInd + search.length; | |
let searchStop = (index<arraySearch.length-1)? conteudoNoBlankLines.indexOf("#",serachStart) -1 : serachStart+20; | |
let valueFound = conteudoNoBlankLines.substring(serachStart,searchStop).trim(); | |
map[element] = valueFound; | |
}); | |
console.log(map); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment