GitHub Action
IssueOps Form Parser
Convert issue form responses to JSON
This action is designed to be used in conjunction with issue forms to allow you to parse created issues into machine-readable JSON for processing.
Issues submitted using issue forms use a structured Markdown format. So long as the issue body is not heavily modified by the user, we can reliably parse the issue body into a JSON object.
You can use this action to conditionally run steps in a workflow based on the contents of the issue body. For example, you may want to run a step only if the issue body contains a specific keyword, version number, etc.
Here is a simple example of how to use this action in your workflow. Make sure
to replace vX.X.X
with the latest version of this action.
steps:
- name: Parse Issue
id: parser
uses: issue-ops/[email protected]
with:
body: ${{ github.event.issue.body }}
- name: Output Issue JSON
id: output-issue
run: echo ${{ steps.parser.outputs.json }}
Input | Description |
---|---|
body |
The issue body to parse (${{ github.event.issue.body }} ) |
csv_to_list |
Convert single-line responses with commas to lists (true ) |
Output | Description |
---|---|
json |
The parsed issue as a JSON string |
Given the following issue body:
### Your contact details
[email protected]
### What happened?
A bug happened!
### Version
1.0.0
### What browsers are you seeing the problem on?
Chrome, Safari
### What else?
- [x] Never give up
- [ ] Hot Dog is a Sandwich
The output of this action would be:
{
"your_contact_details": "[email protected]",
"what_happened": "A bug happened!",
"version": "1.0.0",
"what_browsers_are_you_seeing_the_problem_on": ["Chrome", "Safari"],
"code_of_conduct": {
"selected": ["Never give up"],
"unselected": ["Hot Dog is a Sandwich"]
}
}
The following transformations will take place for each heading:
Transformation | Before | After |
---|---|---|
Trim | ### This is a title! :) |
This is a title! :) |
Lowercase | This is a title! :) |
this is a title! :) |
Replace Spaces | this is a title! :) |
this_is__a_title!_:) |
Remove Symbols | this_is_a_title!_:) |
this_is__a_title_ |
Dedupe Underscores | this_is__a_title_ |
this_is_a_title |
The following transformations will take place for responses, depending on the type/format.
Before:
This is a response
After:
This is a response
Note
This can be disable by setting the csv_to_list
parameter to 'false'
.
Before:
These, are, options
After:
["These", "are", "options"]
Note
Empty lines are preserved in multiline responses.
Before:
First line :D
Third line!
After:
First line :D\n\nThird line!
Before:
- [x] Pick me!
- [ ] Don't pick me D:
After:
{
"selected": ["Pick me!"],
"unselected": ["Don't pick me D:"]
}
In the following situations, an input will be omitted from the output JSON:
Scenario | Example |
---|---|
Invalid Heading | ## This is invalid |
Empty Heading | ### |
This is a value |
|
No Value | ### This is a heading |
<empty> |
|
### This is another |
|
This is a value |