Skip to content

Parses fields of an issue that may or may not have been created via an Issue Template, but without the template, based on the headings

License

Notifications You must be signed in to change notification settings

benlei/parse-issue-templateless

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

benlei/parse-issue-templateless

GitHub Super-Linter CI Check dist/ CodeQL Coverage

This action will try to parse a body, or an issue's body, for fields as if it were created by an issue template. Keep in mind that because this is templateless, it assumes all the contents of each field are strings.

Inputs

Input Name Required Default Description
repository no ${{ github.repository }} The repository to find issue in, if trying to fetch an issue's body
token no ${{ github.token }} The GitHub token to use for searching for issue
body no '' The body to parse
issue-number no '' The issue number to try to fetch the body from for parsing. Ignored if body input is specified/has content.
issue-title no '' The exact issue title to search for to try to fetch the body from for parsing. Ignored if body or issue-number input is specified/has content.
fail-on-error no true Whether or not to fail action if any error occurs

Outputs

Output Name Description
issue-number The issue number that was found, if an issue was fetched/searched for
* The headings are slugified (lowercased, alphanumeric chars only) before having its content set as the output. For example, if you had the heading Hello World, you can expect the output hello-world to have been set from this step

Examples

Parse by Body

- name: Test Local Action - Body
  id: test
  uses: benlei/parse-issue-templateless@v1
  env:
    ISSUE_BODY: |
      ### Issue Title

      This is the body of the issue

      ```yaml
      time: 10
      ```

      And that's about it

      ### Something Else 123

      1235768457246

      ### Third Heading over here...

      Hello World
  with:
    body: ${{ env.ISSUE_BODY }}

- name: Outputs are not correct
  if: |
    steps.test.outputs.issue-number != '' ||
    !contains(steps.test.outputs.issue-title, 'time: 10') ||
    !contains(steps.test.outputs.issue-title, 'about it') ||
    steps.test.outputs.something-else-123 != '1235768457246' ||
    steps.test.outputs.third-heading-over-here != 'Hello World'
  run: exit 1

Parse by Issue Number

- name: Test Local Action - Issue Number
  id: test
  uses: benlei/parse-issue-templateless@v1
  with:
    issue-number: 3

- name: Outputs are not correct
  if: |
    steps.test.outputs.issue-number != '3' ||
    !contains(steps.test.outputs.issue-title, 'time: 10') ||
    !contains(steps.test.outputs.issue-title, 'about it') ||
    steps.test.outputs.something-else-123 != '1235768457246' ||
    steps.test.outputs.third-heading-over-here != 'Hello World'
  run: exit 1

Parse by Exact Issue Title

- name: Test Local Action - Issue Title
  id: test
  uses: benlei/parse-issue-templateless@v1
  with:
    issue-title: Issue with example contents

- name: Outputs are not correct
  if: |
    steps.test.outputs.issue-number != '3' ||
    !contains(steps.test.outputs.issue-title, 'time: 10') ||
    !contains(steps.test.outputs.issue-title, 'about it') ||
    steps.test.outputs.something-else-123 != '1235768457246' ||
    steps.test.outputs.third-heading-over-here != 'Hello World'
  run: exit 1

About

Parses fields of an issue that may or may not have been created via an Issue Template, but without the template, based on the headings

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published