actions-ecosystem/action-regex-match

๐Ÿ” GitHub Action to do regex matching

118

stars

23

commits

TypeScript

primary language

Mar 20, 2024

updated

github.com/marketplace/actions/actions-ecosystem-action-regex-match
actions
github
regex

README

Action Regex Match

actions-workflow-test release license

This is a GitHub Action to do regex matching and output the matched text and groups captured by the given regex.

GitHub Actions natively supports some helpful functions, like contains and startsWith, but doesn't regex matching. This actions provides the missing, useful function.

It would be more useful to use this with other GitHub Actions' outputs.

Inputs

NAMEDESCRIPTIONTYPEREQUIREDDEFAULT
textA text as the target for inputs.regex.stringtrueN/A
regexA regex for inputs.text. Supports capturing groups.stringtrueN/A
flagsFlags for inputs.regex. e.g.) 'g', 'gm'stringfalse''

Outputs

NAMEDESCRIPTIONTYPE
matchThe whole matched text. If the inputs.regex doesn't match inputs.text, this value is ''.string
group1The 1st captured group.string
group2The 2nd captured group.string
group3The 3rd captured group.string
group4The 4th captured group.string
group5The 5th captured group.string
group6The 6th captured group.string
group7The 7th captured group.string
group8The 8th captured group.string
group9The 9th captured group.string

Example

name: Add Label with Comment

on: [issue_comment]

jobs:
  create_comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-regex-match@v2
        id: regex-match
        with:
          text: ${{ github.event.comment.body }}
          regex: '^/label\s*(.*?)\s*$'

      - uses: actions-ecosystem/action-add-labels@v1
        if: ${{ steps.regex-match.outputs.match != '' }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          labels: ${{ steps.regex-match.outputs.group1 }}
name: Create Comment with Regex Match

on: [issue_comment]

jobs:
  create_comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-regex-match@v2
        id: regex-match
        with:
          text: ${{ github.event.comment.body }}
          regex: '```typescript([\s\S]*)```'
          flags: gm

      - uses: actions-ecosystem/action-create-comment@v1
        if: ${{ steps.regex-match.outputs.match != '' }}
        with:
          github_token: ${{ secrets.github_token }}
          body: |
            Hello, @${{ github.actor }}!

            The raw TypeScript code is here.

            ---

            ${{ steps.regex-match.outputs.group1 }}

            ---

License

Copyright 2020 The Actions Ecosystem Authors.

Action Regex Match is released under the Apache License 2.0.

Contributors

micnncim

15 commits

zml2008

1 commits

actions-ecosystem/action-regex-match

๐Ÿ” GitHub Action to do regex matching

118

stars

23

commits

TypeScript

primary language

Mar 20, 2024

updated

github.com/marketplace/actions/actions-ecosystem-action-regex-match
actions
github
regex

README

Action Regex Match

actions-workflow-test release license

This is a GitHub Action to do regex matching and output the matched text and groups captured by the given regex.

GitHub Actions natively supports some helpful functions, like contains and startsWith, but doesn't regex matching. This actions provides the missing, useful function.

It would be more useful to use this with other GitHub Actions' outputs.

Inputs

NAMEDESCRIPTIONTYPEREQUIREDDEFAULT
textA text as the target for inputs.regex.stringtrueN/A
regexA regex for inputs.text. Supports capturing groups.stringtrueN/A
flagsFlags for inputs.regex. e.g.) 'g', 'gm'stringfalse''

Outputs

NAMEDESCRIPTIONTYPE
matchThe whole matched text. If the inputs.regex doesn't match inputs.text, this value is ''.string
group1The 1st captured group.string
group2The 2nd captured group.string
group3The 3rd captured group.string
group4The 4th captured group.string
group5The 5th captured group.string
group6The 6th captured group.string
group7The 7th captured group.string
group8The 8th captured group.string
group9The 9th captured group.string

Example

name: Add Label with Comment

on: [issue_comment]

jobs:
  create_comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-regex-match@v2
        id: regex-match
        with:
          text: ${{ github.event.comment.body }}
          regex: '^/label\s*(.*?)\s*$'

      - uses: actions-ecosystem/action-add-labels@v1
        if: ${{ steps.regex-match.outputs.match != '' }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          labels: ${{ steps.regex-match.outputs.group1 }}
name: Create Comment with Regex Match

on: [issue_comment]

jobs:
  create_comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-regex-match@v2
        id: regex-match
        with:
          text: ${{ github.event.comment.body }}
          regex: '```typescript([\s\S]*)```'
          flags: gm

      - uses: actions-ecosystem/action-create-comment@v1
        if: ${{ steps.regex-match.outputs.match != '' }}
        with:
          github_token: ${{ secrets.github_token }}
          body: |
            Hello, @${{ github.actor }}!

            The raw TypeScript code is here.

            ---

            ${{ steps.regex-match.outputs.group1 }}

            ---

License

Copyright 2020 The Actions Ecosystem Authors.

Action Regex Match is released under the Apache License 2.0.

Contributors

micnncim

15 commits

zml2008

1 commits

Languages

TypeScript

55.8%

JavaScript

44.2%