Skip to content
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

Download artifacts of latest build #21

Open
davidmoremad opened this issue Oct 5, 2019 · 11 comments
Open

Download artifacts of latest build #21

davidmoremad opened this issue Oct 5, 2019 · 11 comments

Comments

@davidmoremad
Copy link

davidmoremad commented Oct 5, 2019

I'm working with two workflows in different platforms (A and B) and the workflow B needs an artifact of the workflow A. Also, I'm trying to avoid external services as S3 in order to make it simple.

Is there a way to get a link to the artifacts generated in the last build (latestbuild) or in the last passed build (lastsuccessfulbuild)?

Maybe something like this: https://github.com/{account}/{repo}/workflows/{workflowName}/builds/latest/artifacts/file.zip

@bokuweb
Copy link

bokuweb commented Oct 5, 2019

I would like to know how to get link url too. ref #2 (comment)

wez added a commit to wez/watchman that referenced this issue Nov 1, 2019
I'd like to link directly to the downloads but that depends on
actions/upload-artifact#21

Closes facebook#755
Closes facebook#746
Closes facebook#741
Closes facebook#683
facebook-github-bot pushed a commit to facebook/watchman that referenced this issue Nov 2, 2019
Summary:
I'd like to link directly to the downloads but that depends on
actions/upload-artifact#21

Closes #755
Closes #746
Closes #741
Closes #683
Pull Request resolved: #758

Differential Revision: D18283531

Pulled By: wez

fbshipit-source-id: aabf52c8d3f873bae05808296f00f139afd7d716
@konradpabjan
Copy link
Collaborator

This is more of an issue on the download-artifact side. See: actions/download-artifact#3

No rough ETA but this is something that we really really want to do since it will help enable more complete CI/CD experiences.

@JayFoxRox
Copy link

JayFoxRox commented Feb 2, 2020

Also see related discussions like #27 and #50.

We would like a direct URL for our nightly builds (like the format proposed in the issue description).
We don't want to trash our repositories GitHub Releases for nightly binaries / many tagged releases - we are also fine with short retention for nightly builds.

We had previously used Travis CI and AppVeyor CI, where none of this was any issue. With GitHub Actions it's a massive headache / various issues.

I had made a quick and dirty tool to redirect users to the latest artifact URL using the new API.
This tool is at https://github.com/JayFoxRox/GitHub-artifact-URL/

However, now the actions API and artifact URLs only work for authenticated users: JayFoxRox/GitHub-artifact-URL#4 so the tool doesn't even work for our use-case anymore (which is frustrating, as we waited for a solution for weeks, and had manually updated the download URL on our website for now).
I think a simple script like mine would still work for other use-cases in this issue, though.

I have created #51 for the permission issue.

@eine
Copy link

eine commented May 15, 2020

@JayFoxRox, you might find eine/tip useful or, at least, inspiring. As a matter of fact, I wrote that action in JavaScript several months ago. Artifacts were not supported, so my strategy was to use a single pre-release and update it. It didn't work as expected, because recreating the release would spam all watchers.

Then, I rewrote it as a Docker Action in Python. The pre-release is kept, but assets are updated/overwritten, hence notifications are not triggered. The usage of tip is similar to this action. Precisely, I accumulate all the artifacts with upload-artifact and I use an additional job to update the "nightly" release:

  nightly:
    needs: [ lin, win ]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/download-artifact@v2
      with:
        path: ./
    - uses: eine/tip@master
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        tag: 'nightly'
        files: |
          ./artifact/*

tip also force-pushes the tag, for it to point to the commit that corresponds to the updated artifacts/assets.

The advantage compared to using GitHub-artifact-URL, is that the pre-relase provides a nice and consistent URL for users to download assets, and no authentication is required: https://github.com/user/repo/releases/download/nightly/artifact_name.ext.

@Titaniumtown
Copy link

Also see related discussions like #27 and #50.

We would like a direct URL for our nightly builds (like the format proposed in the issue description).
We don't want to trash our repositories GitHub Releases for nightly binaries / many tagged releases - we are also fine with short retention for nightly builds.

We had previously used Travis CI and AppVeyor CI, where none of this was any issue. With GitHub Actions it's a massive headache / various issues.

I had made a quick and dirty tool to redirect users to the latest artifact URL using the new API.
This tool is at https://github.com/JayFoxRox/GitHub-artifact-URL/

However, now the actions API and artifact URLs only work for authenticated users: JayFoxRox/GitHub-artifact-URL#4 so the tool doesn't even work for our use-case anymore (which is frustrating, as we waited for a solution for weeks, and had manually updated the download URL on our website for now).
I think a simple script like mine would still work for other use-cases in this issue, though.

I have created #51 for the permission issue.

Thank you so much!

@tonyhallett
Copy link

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

sarcasticadmin added a commit to socallinuxexpo/scale-network that referenced this issue Aug 30, 2021
The upload workflow within github actions leaves a lot to be desired.
There were many initial assumptions with GITHUB_WORKSPACE, paths from
test repos, etc. that were originally left here. These more or less have
been vetted now and this is the best result I have found to date for
scale-network.

Additionally, I am watching a few upstream stories in the upload actions
repo just to see if it improves things for us in the near term:
  - actions/upload-artifact#109
  - actions/upload-artifact#21
sarcasticadmin added a commit to socallinuxexpo/scale-network that referenced this issue Aug 30, 2021
The upload workflow within github actions leaves a lot to be desired.
There were many initial assumptions with GITHUB_WORKSPACE, paths from
test repos, etc. that were originally left here. These more or less have
been vetted now and this is the best result I have found to date for
scale-network.

Additionally, I am watching a few upstream stories in the upload actions
repo just to see if it improves things for us in the near term:
  - actions/upload-artifact#109
  - actions/upload-artifact#21
sarcasticadmin added a commit to socallinuxexpo/scale-network that referenced this issue Oct 2, 2021
The upload workflow within github actions leaves a lot to be desired.
There were many initial assumptions with GITHUB_WORKSPACE, paths from
test repos, etc. that were originally left here. These more or less have
been vetted now and this is the best result I have found to date for
scale-network.

Additionally, I am watching a few upstream stories in the upload actions
repo just to see if it improves things for us in the near term:
  - actions/upload-artifact#109
  - actions/upload-artifact#21
@Kagami
Copy link

Kagami commented Jan 16, 2024

Solution similar to @eine

See: #51 (comment)

@Willsr71
Copy link

For those looking to grab this in bash, here's a short script for grabbing by workflow run and artifact name: https://gist.github.com/Willsr71/e4884be88f98b4c298692975c0ec8edb

@SilverFire
Copy link

SilverFire commented Oct 4, 2024

The same done in two lines of gh, which is available by default in GitHub Actions.

      - name: 'Download latest successful build artifact'
        run: |
          gh_last_success_run_id=$(gh run list -w $WORKFLOW --json conclusion,headBranch,databaseId --jq 'first(.[] | select(.conclusion | contains("success"))) | .databaseId')
          [ -z "$gh_last_success_run_id" ] && echo "No successful run found" && exit 1 || true
          gh run download $gh_last_success_run_id -n $ARTIFACT_NAME -D $OUTPUT_DIR
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          WORKFLOW: .github/workflows/build.yaml
          ARTIFACT_NAME: application
          OUTPUT_DIR: app/build

Where the variables are as follows:

  1. WORKFLOW: The path to the GitHub Actions workflow file that is being targeted.

  2. ARTIFACT_NAME: The name of the artifact that was produced by the successful workflow run.

  3. OUTPUT_DIR: The directory path where the downloaded artifact will be unpacked.

Make sure your job has at least a read access to the actions context:

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      actions: 'read'

@Snowiiii
Copy link

Snowiiii commented Oct 13, 2024

Hello, I would like to enable users to download latest commits from my GitHub pages page. Something like @davidmoremad mentioned https://github.com/{account}/{repo}/workflows/{workflowName}/builds/{platform}latest/artifacts/file.zip would be ideal. Is there any progress ?
I saw actions/download-artifact#3 is already closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests