dsaltares / fetch-gh-release-asset

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

Using 'regex' to download multiple files renames files #48

Open samspencer5991 opened 2 years ago

samspencer5991 commented 2 years ago

I'm currently using this to download all available files from the repo in my GH action. The issue is that the downloaded files are then renamed with the passed file name with the original filename appended.

For example, in my repo I have four files, all beginning with 'bridge'. So I can download all of them by passing file: "bridge", but then my files end up looking like: "bridgebridge...."

Is there a way to avoid this and just keep the original file names?

Korkman commented 2 years ago

As a workaround, specify target: "./"

dsaltares commented 2 years ago

The issue is that target is the full target file path. In the context of downloading multiple files, this option makes a bit less sense. Not all downloaded files can have the same target file path because they would collide.

There are 2 options.

  1. We change target to mean target directory, which would solve your problem but would be a backwards-incompatible change that needs to be released under a new major version.
  2. You use the workaround suggested by @Korkman, target: "./".

@samspencer5991 what do you think?

afk-mario commented 2 years ago

I specified the target but still get the files renamed not sure if I'm doing something wrong

      - name: download latest build
        id: get_release
        uses: dsaltares/fetch-gh-release-asset@1.0.0
        with:
          version: "latest"
          file: "don-salmon-.*\\.zip"
          regex: true
          target: "./"
          token: "${{ secrets.GITHUB_TOKEN }}"
dechamps commented 10 months ago

I just hit the same issue - basically, the problem is that the combination of this line:

https://github.com/dsaltares/fetch-gh-release-asset/blob/5d24fa77c1ae2e1e1dea54677d267f127d5de53a/index.ts#L139

And this line:

https://github.com/dsaltares/fetch-gh-release-asset/blob/5d24fa77c1ae2e1e1dea54677d267f127d5de53a/index.ts#L155

Results in hilarity when the config is something like:

      - uses: dsaltares/fetch-gh-release-asset@1.1.1
        with:
          file: '.+\.(tar\.gz|whl)$'
          regex: true

@Korkman's workaround of setting target to ./ works because that prevents target from being set to file. Ideally that should just be the default behaviour.