sean0x42 / markdown-extract

Extract sections of a markdown file. Useful for automatically extracting changelogs
https://hub.docker.com/r/sean0x42/markdown-extract
MIT License
29 stars 8 forks source link

Action doesn't work #19

Open dannysauer opened 1 year ago

dannysauer commented 1 year ago

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 commented 1 year ago

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

sean0x42 commented 1 year ago

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

dannysauer commented 1 year ago

...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.