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

GitHub Issue Parser

v3.0.0

GitHub Issue Parser

check-square

GitHub Issue Parser

Use this action to convert issues into a unified JSON structure

Installation

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

              

- name: GitHub Issue Parser

uses: stefanbuck/[email protected]

Learn more about this action in stefanbuck/github-issue-parser

Choose a version

GitHub Issue Parser

GitHub release snyk

Use this action to convert issues into a unified JSON structure. Read the Codeless Contributions with GitHub Issue Forms post on my blog.

Setup

- uses: stefanbuck/github-issue-parser@v3
  id: issue-parser
  with:
    issue-body: ${{ github.event.issue.body }} # required
    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 }}

Migrate from v2 to v3

-- uses: stefanbuck/github-issue-parser@v2
+- uses: stefanbuck/github-issue-parser@v3
  id: issue-parser
  with:
+   issue-body: ${{ github.event.issue.body }}
    template-path: .github/ISSUE_TEMPLATE/bug-report.yml

Example

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

Action outputs

  • jsonString - The entire output
  • issueparser_<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.

Real-world examples

Basic example

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.

See workflow

Awesome list

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.

See workflow

Advanced Issue Labeler

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.

How to use it