Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
check-square

GitHub Action

IssueOps Form Parser

v0.1.1

IssueOps Form Parser

check-square

IssueOps Form Parser

Convert issue form responses to JSON

Installation

Copy and paste the following snippet into your .yml file.

              

- name: IssueOps Form Parser

uses: issue-ops/[email protected]

Learn more about this action in issue-ops/parser

Choose a version

IssueOps Parser

Check dist/ CodeQL Continuous Integration Super Linter Code Coverage

Convert issue form responses to JSON

About

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.

Setup

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 }}

Inputs

Input Description
body The issue body to parse (${{ github.event.issue.body }})
csv_to_list Convert single-line responses with commas to lists (true)

Outputs

Output Description
json The parsed issue as a JSON string

Example

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"]
  }
}

Transformations

Headings

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

Values

The following transformations will take place for responses, depending on the type/format.

Single Line

Before:

This is a response

After:

This is a response

Single Line with Commas

Note

This can be disable by setting the csv_to_list parameter to 'false'.

Before:

These, are, options

After:

["These", "are", "options"]

Multiline

Note

Empty lines are preserved in multiline responses.

Before:

First line :D

Third line!

After:

First line :D\n\nThird line!

Checkboxes

Before:

- [x] Pick me!
- [ ] Don't pick me D:

After:

{
  "selected": ["Pick me!"],
  "unselected": ["Don't pick me D:"]
}

Omitting Inputs

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