-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support artifact URL output #50
Comments
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 Do you know why it's to be expired after 1 minute? |
I do not know why, that is just what their documentation says. |
Unfortunately you can't retrieve the artifact during current workflow run, it will become available in the API only after the current run finishes... |
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 |
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 wonder if you could use https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run then to process that |
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. |
+1 for this, or at least the artifact id. 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. |
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...). |
💯 would love to see this feature. I attempted to run 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. |
The github actions API doesn't play well with per commit artifacts. For now we create a release when pushing a tag. Consuming the per commit artifacts w/o the github actions API is blocked by this: actions/upload-artifact#50
* Binary release creation workflows This PR adds the ability to upload release artifact via XCHammer's github CI and it creates a release when pushing a tag to v* The github actions API doesn't play well with per commit artifacts. For now we create a release when pushing a tag. Consuming the per commit artifacts w/o the github actions API is blocked by this: actions/upload-artifact#50
@jerrymarino afaict the url is stable, but you have to follow the redirect to get the artifact. |
@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
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 yeah, you are using the wrong initial url. you need to use the one here which is stable: 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. |
@ghutchis @abhijitvalluri |
Any updates? There's a real intention to provide the ID after the upload? |
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. |
So v4 just released today: https://github.blog/changelog/2023-12-14-github-actions-artifacts-v4-is-now-generally-available/ With it there is an artifact ID output that is immediately available and it's the same ID that is used in the current URL: https://github.com/actions/upload-artifact?tab=readme-ov-file#using-outputs So with another API call to get the check suite ID it should be possible to construct an artifact URL. The current URL that is in the format of Renamed the issue but long term this should look like this:
|
Thank you for the improvements to the Artifact upload/download. I am wondering if it is possible to have the Artifact go into a permanent URL? I would like my GitHub repo Readme.md file have the URL in the main document, so people can download the Artifact directly. Similar to how the Releases / Latest buttom works. But ideally it would be just a fixed URL, and where the latest Artifact always overwrites the fixed URL. thank you |
Thanks @konradpabjan for the heavy lifting that has gone into v4! I've just tried the following, and that simply worked, I could download the artifact from the URL this generated, no suite-ID or other complications required. So to me this says, the main usecase as outlined in the issue description is now supported by v4 (even if it might be made more convenient to use later on :), which is great news if true! 🎉 (Or did I misunderstand your message, is this a happy accident that is not guaranteed to work, or something else entirely?) - uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: my-artifact
path: path/to/artifact/content/
- name: Output artifact URL
run: echo 'Artifact URL is ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}' |
@wosc Yeah so another teammate recently made the URL changes I described and the artifact URLs in the UI now doesn't rely on the check suite ID so things are much simpler! 🎉 Creating a URL with the run ID and artifact ID is now reliable and users can use this to potentially embed artifact links in a host of different places such as PR descriptions, READMEs or issues. I've gone ahead and merged in changes that support an The PR was merged into As described in my earlier content, with
An important thing to keep in mind is that this URL behavior is exactly as if downloading artifacts from the run summary page in the UI. You must be logged into GitHub for it to work (if browsing as incognito than the URL doesn't even show up). If you do get your hands on a URL while not logged in than it will 404 and prompt you to login. This is for a few scenarios i've seen mentioned where if you take this URL and embed it in some external website and a non-GitHub users tries to click it (anonymous request) than it will 404 and prompt for a download. That's the way it is due to bad actors/security. Logs follows the same pattern where anonymous users/bots can't view & download logs as this opens up a DDOS/attack vector that we can protect ourselves by requiring a simple login. If you really need a download URL that works for users/services that are aren't authenticated with GitHub then the existing API that generates a 1 minute download URL is your only option. If you want some download URL for anonymous downloads for an extended period of time than unfortunately we aren't planning on supporting that due to the security concerns outlined earlier. The plus side of this URL that is now outputted is that it will work as long as the artifact has not expired. The only other caveats are the run must not be deleted alongside the repository. If your artifact has a retention period of 100 days for example than you can add this URL to a |
Amazing Konrad, thank you for the update! Friendly reminder for users not to use this new feature for stable releasing... download the artifact from a workflow run and upload the files to the release as (different type of) artifacts for permanent storage on the Releases. |
Thank you Konrad and team, that's excellent news! |
1. Make `id` more descriptive so there's less chance of a name clash. 2. Update to version 4 of the `upload-artifact` action, as [that brings with it the rather cool option to get the artifact URL immediately](actions/upload-artifact#50 (comment)).
What is the correct syntax to include the URL in a markdown README.md file? |
Hello @konradpabjan
I tried to get that url using curl with "token ${{ secrets.GITHUB_TOKEN }}" and got the error "Resource not accessible by integration". |
@konradpabjan https://github.com/actions/upload-artifact/blob/v4/action.yml#L50 |
Ah, forgot to close this issue out after #496 went in and the v4 tag was updated. Closing out now |
+1. This is also what I would wish. |
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:
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:
The last command would display something like:
The text was updated successfully, but these errors were encountered: