dsaltares / fetch-gh-release-asset

Github Action to download an asset from a Github release
MIT License
113 stars 70 forks source link

Some questions #49

Closed MkQtS closed 1 year ago

MkQtS commented 2 years ago

First one is about regex. The example of regular expression in the README file is:

regex: true
file: "plague-.*\\.zip"

Two backslash were used there. But we just need one backslash to interpret in regex, two backslash actually means a backslash itself. However, as far as I know, we may need two backslash to interpret in Java, the first one is for Java interpreter.

If the regex used here is Java style and we need two backslash to interpret, I think it would be better if we add some tips in the README.

Another question is, there may be a case that no file in releases were matched, caused by typo or the target doesn't exist at all. I haven't used the project yet, does the project provide an error code as Outputs? (If so, we can use GitHub Action's if in the next step to handle such case.)

Thanks.

joonas-fi commented 1 year ago

Two backslashes are due that being a string in YAML. It'll end up as one backslash when the YAML is parsed:

image

dsaltares commented 1 year ago

Thanks @joonas-fi for answering the first question, much appreciated.

@MkQtS to answer the second question, when no file is found, we just throw an error and exit early. You can see this here https://github.com/dsaltares/fetch-gh-release-asset/blob/master/index.ts#L150. We don't set a specific error code on outputs. I guess it would fall to whatever action error behaviour GH has. I think that's a non zero exit code, but it won't be a specific one.

The docs allow you to explicitly set an action to failed, but it doesn't let you set a specific numerical code either https://github.com/actions/toolkit/tree/main/packages/core#exit-codes.

This action assumes you know the file you're looking for and that it is certain or very likely to exist.

@MkQtS does this answer your question?

MkQtS commented 1 year ago

@joonas-fi, @dsaltares, thank you for your clear replies, I get it now.