Code Monkey home page Code Monkey logo

Comments (13)

konradpabjan avatar konradpabjan commented on July 28, 2024 31

Currently it is not possible to not fail the workflow if no artifact is found

Some customization is on the way for upload-artifact: actions/upload-artifact#104

Perhaps a similar option could prove useful for download-artifact. Something like if-no-artifact: with options error, warn or ignore? 🤔

from download-artifact.

jkowalleck avatar jkowalleck commented on July 28, 2024 7

@benjamincharity maybe use
continue-on-error: true -- see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error

from download-artifact.

xSAVIKx avatar xSAVIKx commented on July 28, 2024 5

Stumbled across this need and found no way of checking if some artifact exists. So created a new action: https://github.com/marketplace/actions/check-artifact-existence

You can add a new step that is going to expose and output denoting if an artifact exists or not by the given artifact name:

uses: actions/xSAVIKx/artifact-exists-action@v0
id: check_coverage_artifact
with:
  name: 'coverage-artifact'

Then you can use steps.check_coverage_artifact.outputs.exists (true/false) in the conditions.

from download-artifact.

jkowalleck avatar jkowalleck commented on July 28, 2024 3

@benjamincharity you should check on this again.

i dd a quick playground to replicate the behavior you described.

i used continue-on-error: true
it marks the workflow as passed, badges are passed.
even the step is marked as passed. see https://github.com/jkowalleck/playground_download-artifact_issue-42/runs/1022858445?check_suite_focus=true

PS:
nevertheless i like idea of @konradpabjan as of #42 (comment)

from download-artifact.

benjamincharity avatar benjamincharity commented on July 28, 2024 2

@jkowalleck thanks for calling this out. From your test it sure does looks like you are correct. I'll be happy to be wrong on this 😄 I will give it a test as soon as I can. Thanks!

from download-artifact.

maapteh avatar maapteh commented on July 28, 2024 1

Hi, we fixed it in if statement. We check for existence of coverage file:

      - name: Check file existence for sonar integration
        id: sonar
        uses: andstor/file-existence-action@v1
        with:
          files: "sonar-project.properties, coverage/lcov.info"

      - name: Upload coverage file
        if: steps.sonar.outputs.files_exists == 'true'
        uses: actions/upload-artifact@v2
        with:
          name: coverage-file
          path: coverage/lcov.info

hope it helps someone, we made it defensive since its a pipeline for multiple apps. Some are mature and some not :)

from download-artifact.

iSuslov avatar iSuslov commented on July 28, 2024 1

Just don't use this action and call gh directly:

      - name: Download artifact
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: echo $(gh run download -n my-artifact-name)

https://cli.github.com/manual/gh_run_download

from download-artifact.

mdreizin avatar mdreizin commented on July 28, 2024

Any updates on this issue?

from download-artifact.

raymiranda avatar raymiranda commented on July 28, 2024

Currently it is not possible to not fail the workflow if no artifact is found

Some customization is on the way for upload-artifact: actions/upload-artifact#104

Perhaps a similar option could prove useful for download-artifact. Something like if-no-artifact: with options error, warn or ignore? 🤔

I was having the same issue. After reviewing the method used, I can see that if you don't specific a name on the download, it will attempt to create the directories regardless.

const artifactClient = artifact.create() if (!name) { // download all artifacts core.info('No artifact name specified, downloading all artifacts') core.info( 'Creating an extra directory for each artifact that is being downloaded' )

This worked for me as a work around.

from download-artifact.

benjamincharity avatar benjamincharity commented on July 28, 2024

@benjamincharity maybe use
continue-on-error: true -- see docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error

I called this out in the original edit. There are multiple ways to functionally unblock ourselves to get around this, but from what I've seen each method will still mark our workflow as failed in the PR and primary repo badge. So any contributor or consumer needs to actually go see if our build is really failing or if it is just one optional step that is failing.

from download-artifact.

rethab avatar rethab commented on July 28, 2024

@konradpabjan would you accept a PR that adds the if-no-artifact input as you suggested?

from download-artifact.

Sonicfury avatar Sonicfury commented on July 28, 2024

Hi, we fixed it in if statement. We check for existence of coverage file:

      - name: Check file existence for sonar integration
        id: sonar
        uses: andstor/file-existence-action@v1
        with:
          files: "sonar-project.properties, coverage/lcov.info"

      - name: Upload coverage file
        if: steps.sonar.outputs.files_exists == 'true'
        uses: actions/upload-artifact@v2
        with:
          name: coverage-file
          path: coverage/lcov.info

hope it helps someone, we made it defensive since its a pipeline for multiple apps. Some are mature and some not :)

Actually not sure it solves anything because we're talking about download here. How would you check that the file in the artifact exists if it isn't downloaded yet ?

Did someone find a workaround ?

@benjamincharity maybe use continue-on-error: true -- see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error

This would be the best solution imho.

I'll probably make an action myself returning true or false as an output if there are artifacts. I can't think of another way to do it for now

from download-artifact.

ryooo avatar ryooo commented on July 28, 2024

In my case, I was able to do the following.

      - id: check-artifact-exist
        run: |
          url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${run-id}/artifacts"
          echo "artifact-name=$(curl -fsSL "$url" | jq -r '.artifacts[0].name')" >> $GITHUB_OUTPUT
      - uses: actions/download-artifact@v4
        if:
          ${{ steps.check-artifact-exist.outputs.artifact-name ==
          'xxx' }}

from download-artifact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.