Use this action to convert issues into a unified JSON structure. Read the Codeless Contributions with GitHub Issue Forms post on my blog.
- uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/bug-report.yml # optional but recommended
- run: cat ${HOME}/issue-parser-result.json
- run: echo $FAVORITE_DISH
env:
FAVORITE_DISH: ${{ steps.issue-parser.outputs.issueparser_favorite_dish }}
The text to be parsed can be set explicitly using issue-body
input, otherwise it can be left to use the default value of ${{ github.event.issue.body }}
.
Given an issue form
body:
- type: input
id: favorite_dish
attributes:
label: What's your favorite dish?
validations:
required: true
- type: checkboxes
id: favorite_color
attributes:
label: What's your preferred color?
options:
- label: Red
- label: Green
- label: Blue
And an issue body
### What's your favorite dish?
Pizza
### What's your preferred color?
- [x] Red
- [ ] Green
- [x] Blue
The actions output will be
{
"favorite_dish": "Pizza",
"favorite_color": ["Red", "Blue"]
}
jsonString
- The entire outputissueparser_<field_id>
- Access individual values
Please take a look at GitHub's Good practices for mitigating script injection attacks when using inline scripts. The examples blow are safe because they use intermediate environment variable as suggested by GitHub.
- run: echo $JSON_STRING > output.json
env:
JSON_STRING: ${{ steps.issue-parser.outputs.jsonString }}
- run: echo $FAV_DISH
env:
FAV_DISH: ${{ steps.issue-parser.outputs.issueparser_favorite_dish }}
Want to learn more about this concept? Check out the Codeless Contributions with GitHub Issue Forms post on my blog.
Ever wanted to order a pizza from a GitHub Issue? In this basic example, the order is processed and appended to the README using this Action.
The awesome-browser-extensions-for-github repository is using this Action to make it super easy to submit a new extension just by filling a new GitHub Issue. The workflow runs and turns the issue into a code contribution once the label merge
has been added.
The advanced-issue-labeler GitHub Action enables policy-based issue labeling. With the power of GitHub Issue forms and github-issue-parser
, it provides a secure way to label issues to help with the triaging process automatically.