upload-artifact icon indicating copy to clipboard operation
upload-artifact copied to clipboard

Support artifact URL output

Open lelegard opened this issue 5 years ago • 67 comments

Hi,

This suggestion has been discussed here in the GitHub community forum.

In a Github Actions job, after an upload-artifact step, I would like to get the URL of the published artifact in a subsequent step.

The idea is a job using the following steps:

  • Build a binary.
  • Upload the binary as artifact.
  • Trigger a REST API in some Web server, passing the URL of the artifact in a POST parameter, so that the remote server can download the artifact.

How would you get the URL of the artifact in a subsequent step?

I know that there is an Actions API currently in development. But, here, the question is about passing information from the upload-artifact step to the next step.

It could be something like this:

    - name: Upload build
      uses: actions/upload-artifact@master
      with:
        name: installer
        path: installer.exe
        env-url: FOOBAR
    - name: Use URL for something
      run: echo "${{ env.FOOBAR }}"

The last command would display something like:

https://github.com/user/repo/suites/123456/artifacts/789123

lelegard avatar Jan 28 '20 11:01 lelegard

Ideally you could set it so the links do not expire, and they would serve the correct Content-Type so you could link to images/gifs/videos.

It seems you can get an artifact url via https://developer.github.com/v3/actions/artifacts but the links expire within 1 minute.

jperl avatar Jan 31 '20 02:01 jperl

@jperl Do you know why it's to be expired after 1 minute?

jjangga0214 avatar Mar 08 '20 14:03 jjangga0214

I do not know why, that is just what their documentation says.

jperl avatar Mar 08 '20 14:03 jperl

@jperl Hmm, I see. I made an independent issue, https://github.com/actions/upload-artifact/issues/60. This is just letting you know, for the case you want to subscribe or participate in it :)

jjangga0214 avatar Mar 09 '20 15:03 jjangga0214

It seems you can get an artifact url via https://developer.github.com/v3/actions/artifacts but the links expire within 1 minute.

Unfortunately you can't retrieve the artifact during current workflow run, it will become available in the API only after the current run finishes...

lanyizi avatar Jun 04 '20 23:06 lanyizi

This would be a really nice feature to have! I'm working on a Docker image GitHub Action and I want to upload some assets before running my action so they can be used inside the Docker container. If the upload-artifact action provides a URL to the asset as an output, the I can pass this output as an argument to my action and download the asset using curl from inside Docker container.

chshersh avatar Jul 11 '20 12:07 chshersh

I'm going to bump this again. Many people have asked for this feature - both here, discussions, even Stack Overflow

For example, I'd really like to have the artifact URLs posted as a comment for pull requests. At the moment, this seems impossible because the URL is not available to the current workflow.

ghutchis avatar Sep 13 '20 17:09 ghutchis

It seems you can get an artifact url via https://developer.github.com/v3/actions/artifacts but the links expire within 1 minute.

Unfortunately you can't retrieve the artifact during current workflow run, it will become available in the API only after the current run finishes...

I wonder if you could use https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run then to process that

domenkozar avatar Sep 22 '20 07:09 domenkozar

I'm going to bump this again. Many people have asked for this feature - both here, discussions, even Stack Overflow

For example, I'd really like to have the artifact URLs posted as a comment for pull requests. At the moment, this seems impossible because the URL is not available to the current workflow.

I was hoping to do this exact thing! I would love to be able to link the artifacts to the pull request for people to download.

abhijitvalluri avatar Sep 27 '20 00:09 abhijitvalluri

+1 for this, or at least the artifact id. @jjangga0214 @jperl the timeout is only for the redirect url. the actual rest endpoint is constant. ref https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact

I'd find this especially useful to use if I split my pull request and release workflows. I could then reference the artifact built and tested in the PR and publish that directly on release.

jeacott1 avatar Sep 30 '20 01:09 jeacott1

Just adding a +1 here - right now, we're considering all sorts of hacky things (uploading artifacts to a seperate FTP server so we can serve links in PRs, woo...).

DanRunfola avatar Oct 01 '20 14:10 DanRunfola

💯 would love to see this feature. I attempted to run curl on the artifact for XCHammer in the browser and was surprised to see it wasn't working. The use case of this feature would be to pull the artifact into Bazel, but it'd need some stable URL to do this.

It seems like the only alternative is to create a release to create a stable URL but that might be confusing and spam the watchers if we end up doing a release per commit.

jerrymarino avatar Oct 01 '20 20:10 jerrymarino

@jerrymarino afaict the url is stable, but you have to follow the redirect to get the artifact.

jeacott1 avatar Oct 01 '20 23:10 jeacott1

@jeacott1 It'd be awesome for the workflow in question it'd work! Perhaps we're talking about different URLs then - I'm hoping to consume the artifact urls on the github website found via browser and they seem incompatible with curl and bazel:

I've attempted to do the following steps to pull artifacts with curl and Bazel

  1. navigate to https://github.com/pinterest/xchammer/actions/runs/283307177 in a web browser
  2. under Artifacts get the link for xchammer by right clicking xchammer ( https://github.com/pinterest/xchammer/suites/1276155763/artifacts/19716224 )
  3. try to pull with curl following redirects curl -L https://github.com/pinterest/xchammer/suites/1276155763/artifacts/19716224 When I ran that command a few mins ago I get Not Found

I circulated though a few other issues and found mentions of artifact URL from a github actions API that lasts 1 minute. Is this the URL you're pointing to?

jerrymarino avatar Oct 02 '20 00:10 jerrymarino

@jerrymarino yeah, you are using the wrong initial url. you need to use the one here which is stable: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact

tldr: GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}

and then follow the redirect

the real issue is that when you save an artifact you dont get the id in a response as reference later.

jeacott1 avatar Oct 02 '20 00:10 jeacott1

@ghutchis @abhijitvalluri I have created this action that creates a comment in pull request and/or associated issues with the link to all / subset of artifacts https://github.com/marketplace/actions/workflow-artifact-pull-request-comment

tonyhallett avatar Apr 06 '21 13:04 tonyhallett

Any updates? There's a real intention to provide the ID after the upload?

Kalgros20 avatar Mar 04 '22 15:03 Kalgros20

It would be really useful to have access to artifacts before run completion. In my case I need retrieve artifacts download URLs and publish it in custom issue comment. And it must be done in one workflow run, I cannot use 2 separate workflows for generating artifacts and publication comment.

mckrava avatar Mar 05 '22 14:03 mckrava

+1 for this feature request.

cdanek avatar Mar 14 '22 17:03 cdanek

+1 - this would be a very useful feature!

matthewcrozier avatar May 11 '22 12:05 matthewcrozier

+1 This feature would save me so many headaches! Would be so awesome!

cansavvy avatar May 11 '22 12:05 cansavvy

+1 Looking forward to this useful feature!!!

shink avatar May 28 '22 10:05 shink

This feature would be nice, looking forward to it too

mattpopa avatar Jun 03 '22 12:06 mattpopa

I originally posted this topic more than two years ago. It got 134 👍 and 23 responses, mostly "I would like it too". The suggestion does not seem too difficult. And we got zero feedback from the Github team. They probably follow their own track and ignore users' requests. This is a bit frustrating. But, let's be realistic, this is a free service, we have no influence.

lelegard avatar Jun 03 '22 21:06 lelegard

Yes, it's a bit frustrating. I've used @tonyhallett action as linked above. It works well for https://github.com/openchemistry/avogadrolibs - It would be great if GitHub added this support, but in the meantime, there is a workaround.

ghutchis avatar Jun 03 '22 21:06 ghutchis

Off topic a bit: but @lelegard free?. Yes, there's a free tier, but there are many paid users.

On topic: this is the second most voted issue in this repo, with an easy fix, I think it deserves an @actions to please check this TL;DR and respond.

@lelegard a tip: in OP you were asking for env., but actions have outputs. Here is live example.

TWiStErRob avatar Jun 16 '22 17:06 TWiStErRob

Off topic a bit: but @lelegard free?. Yes, there's a free tier, but there are many paid users.

@TWiStErRob, is there any kind of "premium support" channel for corporate users who pay, where this kind of request could get some response?

Open source developers and free users acknowledge their lack of influence.

lelegard avatar Jun 16 '22 20:06 lelegard

+1 : this feature would be useful to me.

vwcruzeiro avatar Jun 25 '22 22:06 vwcruzeiro

+1 lol its fantastik and only feature lack that stops my super duper company to buy github organization license

maksimonishchenko avatar Jul 05 '22 03:07 maksimonishchenko

+1 : this would be useful to me.

deco-dev avatar Sep 01 '22 02:09 deco-dev