Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regular expressions are modified with additional backslash escape characters #140

Open
ianjevans opened this issue Mar 12, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ianjevans
Copy link

What happened

I am using the following regex:

[rR]elease [nN]otes? ?(\((\w.+)\):|:) (\w+.*)$

Which in my workflow YAML is as follows:

    steps:
      - uses:       actions-ecosystem/action-regex-match@v2
        id:         regex-match
        with:
          text:     ${{ env.PR_BODY }}
          regex:    '[rR]elease [nN]otes? ?(\((\w.+)\):|:) (\w+.*)$'
          flags:    gm

To match pull request comment strings with release note items.
See example: https://regex101.com/r/L4yv36/1

When I run the action, though, the input regex that gets passed is:

INPUT_REGEX:[rR]elease [nN]otes? ?(\\((\\w.+)\\):|:) (\\w+.*)$

The backslash characters to escape the parentheses and \w tokens are themselves being escaped, making them literal backslash characters instead of regex tokens. This causes the regex to fail.

The escaping occurs regardless of whether I use a flow or block scalar.

What you expected to happen

The INPUT_REGEX should match what I specified in the workflow YAML.

The input regex should be unmodified, or if the characters are being escaped by the YAML processor there needs to be a pre-processor in the action to handle this scenario.

How to reproduce it

      - uses:       actions-ecosystem/action-regex-match@v2
        id:         regex-match
        with:
          text:     'Release notes (sql change): a thing or three'
          regex:     'rR]elease [nN]otes? ?(\((\w.+)\):|:) (\w+.*)$'
          flags:    gm

Environment

Testing my GitHub action using act.

@ianjevans ianjevans added the bug Something isn't working label Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant