dsaltares / fetch-gh-release-asset

Github Action to download an asset from a Github release
MIT License
113 stars 70 forks source link

Failed download with 404 results in success rather than failure #60

Open nealeu opened 9 months ago

nealeu commented 9 months ago

When trying to download something that might not exist, and want to fallback to using if: failure() on the next step, the following expected result happens:

    at /opt/actions-runner/_work/_actions/dsaltares/fetch-gh-release-asset/master/dist/index.js:6356:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (/opt/actions-runner/_work/_actions/dsaltares/fetch-gh-release-asset/master/dist/index.js:13865:19) {
  status: 404,

but, the result of the step is recorded as success:

    - name: Fetch mongodump for {{ inputs.load-mongodump-release }}-${{ steps.current_branch.outputs.branch }}
      id: fetch-mongodump-branch
      if: ${{ inputs.load-mongodump-release }}
      continue-on-error: true # So that the overall job doesn't fail if we recover from this
      uses: dsaltares/fetch-gh-release-asset@master
      with:
        version: tags/${{ inputs.load-mongodump-release }}-${{ steps.current_branch.outputs.branch }}
        file: 'mongodump.zip'

    - name: log previous step conclusion
      if: ${{ inputs.load-mongodump-release }}
      shell: bash
      run: echo "conclusion=${{ steps.fetch-mongodump-branch.conclusion }}" >> $GITHUB_OUTPUT

This means that this step never happens because conclusion is success:

    - name: Fetch mongodump for {{ inputs.load-mongodump-release }}-main
      id: fetch-mongodump-main
      if: ${{ failure() && inputs.load-mongodump-release }}
      uses: dsaltares/fetch-gh-release-asset@master
      with:
        version: tags/${{ inputs.load-mongodump-release }}-main
        file: 'mongodump.zip'