markdown-extract icon indicating copy to clipboard operation
markdown-extract copied to clipboard

Action doesn't work

Open dannysauer opened this issue 2 years ago • 4 comments

The github action passes the filename in as a second argument, but then fails with:

error: Found argument './pr_body' which wasn't expected, or isn't valid in this context

USAGE:
    markdown-extract <pattern> <path> --no-print-matched-heading

For more information try --help
validate test plan

...assuming the filename is "./pr_body" I get the same failure without the leading ./, as well as with an absolute path.

After doing a little bit of research, the workspace in an action is mounted in the container under /github/workspace. So, it'd be nice if either the docs mentioned to prefix files with /github/workspace, or if the action Dockerfile set the workdir to /github/workspace and the docs said to use relative paths.

Or, probably ideally, maybe the binary detects that it's running as an action and does the path translation. Relative path = prefix /github/workspace, absolute path = substitue env $GITHUB_WORKDIR for /github/workspace or alert that the file must be located there if it's not. It's possible to use a different entrypoint in the action metadata. You can specify analternate entrypoint in the action.yml, so this logic could be encapsulated into a shell script which does the arg manipulation and then passes them along to the real program. It could even handle a /github/workspace prefix specially and leave that alone for backwards compatibility.

dannysauer avatar Aug 21 '23 15:08 dannysauer

Actually, I might have conflated two errors. One is that the path is all wonky. The other is that the argument is actually rejected. :D

dannysauer avatar Aug 21 '23 15:08 dannysauer

Hey @dannysauer, thanks for raising! 🙌

I have actually not tested the GitHub action recently, so please let me know if you run into anything else whilst you're using markdown-extract :)

I am currently on vacation, away from my development environment. I'd be happy to take a good look when I'm back online in two weeks time, or if you are blocked and can't wait, I can review a PR for any essential fixes

Cheers

sean0x42 avatar Aug 21 '23 16:08 sean0x42

...and looking closer, the docker run command github uses sets the workdir, so a relative path should just work to begin with. I'm getting an argument parsing error. I wonder if it's because the heading contains a space.

dannysauer avatar Aug 21 '23 16:08 dannysauer

I can confirm that the action also breaks for me if the heading contains a space.

skykooler avatar Jan 06 '25 00:01 skykooler