Xotl / cool-github-releases

MIT License
12 stars 2 forks source link

Input Repository #10

Closed kdumontnu closed 3 years ago

kdumontnu commented 4 years ago

First of all, this project is really well done. Thank you for publishing it.

I'm wondering if you have any plans to add an input option to specify a separate git repository to download release files from, for instance in the form repo:Xotl/cool-github-releases.

For me, I manage a utils repository separate from my main app, and need a way to download those assets to my main project when building. This would be the perfect solution if I can pass a different private repo.

Given the way you've set up the action, it seems possible. I'm happy to help out.

Xotl commented 4 years ago

Hi @kdumontnu,

First of all thanks for using my action and thanks a lot for your kind words, i put some love on this action. 😊

Let me see if this weekend i can have something working. I think that would be a nice feature to have.

PD: Sorry for the late response, i have been quite busy these days.

kdumontnu commented 4 years ago

@Xotl, No worries at all - hopefully you're busy because of some interesting projects going on.

Sounds great! Let me know if I can help in any way.

Xotl commented 4 years ago

Hi @kdumontnu,

Taking a look at the code, it seems that you can specify a different repo and org in the current version of the action. Just set the GITHUB_REPOSITORY environment variable with a string with the next form: <org>/<repo>.

Example:

      - name: Create new release
        uses: Xotl/cool-github-releases@v1
        env:
          GITHUB_REPOSITORY: Xotl/cool-github-releases
        with:
          mode: download
          tag_name: ${{env.NEW_TAG}}

It's not documented since originally it was there for other purposes but you can safely use it. I think i will add a new input for this purpose so the feature looks more integrated into the action (also will document the feature). But probably i will add it later, meanwhile you can use that approach if you need that right away.

If have any questions or issues, please let me know. 😃

kdumontnu commented 4 years ago

Awesome. Thanks for taking a look. I couldn't get it to work with by changing the environment variable (not sure why). HOWEVER, I did find that the input option for repository is already supported in your app, but not in the documentation - that actually worked for me!

https://github.com/Xotl/cool-github-releases/blob/ef50014218e6139d534f725f69aabe3728ea9b2e/src/index.js#L15

The action snippet:

      - name: Download new release
        uses: Xotl/cool-github-releases@v1
        with:
          mode: download
          repository: Xotl/cool-github-releases
Xotl commented 4 years ago

Nice!... i will just document the feature. Thanks for noticing. 😅

miljan-aleksic commented 4 years ago

@Xotl, @kdumontnu this workaround will actually not work as the repository is not declared as a valid action input. I would like to see this supported, though.

Xotl commented 4 years ago

Hey @miljan-aleksic, thanks for reporting this.

You are right, that input it's not declared in the action.yml. I think i'll have some free time this weekend, so will try to add this feature soon.

Hope you guys are enjoying this action. 😄

Xotl commented 4 years ago

Just to let you know guys that the repository input got added to the action.yml and also added some documentation.

Also thanks again for reporting it. 😄

miljan-aleksic commented 4 years ago

Thanks @Xotl !!

I think there is some issue in the code, I have set my yaml as:

name: Download Joomla Installer
uses: Xotl/cool-github-releases@v1
with:
  repository: org/repo
  assets: installer.zip|dist/temp/installer.zip
  github_token: ${{ secrets.TOKEN }}

and getting this error:

Run Xotl/cool-github-releases@v1
No tag or id provided: Looking for the latest release.
Starting the download of asset installer.zip...
Download of assets finished successfully.
fs.js:143
    throw new ERR_INVALID_CALLBACK(cb);
    ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
    at makeCallback (fs.js:143:11)
    at Object.unlink (fs.js:1024:14)
    at WriteStream.l (/home/runner/work/_actions/Xotl/cool-github-releases/v1/dist/index.js:1:37615)
    at WriteStream.emit (events.js:210:5)
    at internal/fs/streams.js:294:12
    at FSReqCallback.oncomplete (fs.js:146:23) {
  code: 'ERR_INVALID_CALLBACK'
}
Xotl commented 4 years ago

Oh i see... will try to fix it ASAP.

Xotl commented 4 years ago

Hi @miljan-aleksic, i added some tests to the workflow in PR #11 and seems that it's working as expected. Do you still experience that issue?.

miljan-aleksic commented 4 years ago

@Xotl, I am sorry to inform that the issue remains, using the exact same configuration as stated before. Worth nothing that I am able to download the artifact using the fabriciobastian/download-release-asset-action.

joseph-flinn commented 3 years ago

@miljan-aleksic I have been messing around with this action for a bit to try to get it to work in my pipeline. After diving into the code to see how the file path is being handled, it seems that the full path has to already exist in order to save your file there.

I do think it would be a cool feature to create the file path if it does not already exist. If I have some spare time, I might take a shot at it.

Xotl commented 3 years ago

@miljan-aleksic I have been messing around with this action for a bit to try to get it to work in my pipeline. After diving into the code to see how the file path is being handled, it seems that the full path has to already exist in order to save your file there.

I do think it would be a cool feature to create the file path if it does not already exist. If I have some spare time, I might take a shot at it.

Hi @joseph-flinn, first of all is great to hear you're interested in this action. 😄

I think i didn't consider those cases in which the full path does not exist, that would be a great feature.

Xotl commented 3 years ago

Now that PR #12 got merged it should create the folder in case it doesn't exists already. This should fix the issue reported by @miljan-aleksic.

Thanks a lot @joseph-flinn for diving into the issue and providing how to solve it. So now i'm closing it.