Why is my upload-release-asset action on GitHub failing?

2k views Asked by At

In my release script I have these actions, among others:

- name: Create Release
    id: createRelease
    uses: actions/create-release@v1
    env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
        tag_name: ${{steps.createReleaseTag.outputs.string}}
        release_name: ${{github.sha}}
        body: Auto-generated prerelease build
        prerelease: true
# yes, we really do have to download the artifact we just uploaded; this job can't see it automatically
- name: Download Artifact
    uses: actions/download-artifact@v2
    with:
        name: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}
        path: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}
- name: Upload Release Asset
    uses: actions/upload-release-asset@v1
    env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
        upload_url: "${{ steps.createRelease.outputs.upload_url }}" # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
        asset_path: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}
        asset_name: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}
        asset_content_type: application/zip

However when I run it I get this output:

Run actions/upload-release-asset@v1
  with:
    upload_url: https://uploads.github.com/repos/ekolis/FrEee/releases/37114727/assets{?name,label}
    asset_path: FrEee.WinForms-cc1b19f204
    asset_name: FrEee.WinForms-cc1b19f204
    asset_content_type: application/zip
  env:
    DOTNET_ROOT: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet
    GITHUB_TOKEN: ***
Error: EISDIR: illegal operation on a directory, read

What's wrong? Is the artifact somehow being treated as a directory instead of a zip file? Does this job not have permission to read the artifact that was created earlier in the action? Is something wrong with the upload URL? (Why does it have {?name,label} in it? It's just the output from the createRelease job...)

1

There are 1 answers

1
Edward Thomson On

It's rather hard to tell what's going on precisely from your question, without seeing the complete workflow file or - better - the workflow run. But GitHub Actions is not a black box - it's just a machine that runs the things that you tell it to run, so if you're asking:

Is the artifact somehow being treated as a directory instead of a zip file?

Then you can just tell it to show you the directory listings. For example: your upload-release-asset action is trying to upload a file named FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}.

But the run complains that this file is a directory. Which certainly seems reasonable given the step before it that downloads a workflow artifact that doesn't have the name .zip in it. You can find out for yourself:

# A previous step has uploaded an artifact to this workflow run.
# Download it to the current virtual machine so that we can create
# a release with it.
- name: Download Artifact
  uses: actions/download-artifact@v2
  with:
    name: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}
    path: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}

# See what we actually downloaded...
- run: ls -FlasR "FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}"

I don't know, but I suspect that you'll find that the error message is correct and you have a directory on disk, not a zip file. In that case, zip it up and upload it as an artifact. You can zip it just like you would on the console.

Then be sure to change your use of the upload-release-asset action to specify the name of the .zip file.

# Since we have a directory, create a zip
- run: zip -r "FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}.zip" "FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}"

# Now upload the zip file
- name: Upload Release Asset
  uses: actions/upload-release-asset@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    upload_url: "${{ steps.createRelease.outputs.upload_url }}" # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
    asset_path: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}.zip
    asset_name: FrEee.WinForms-${{steps.createReleaseTag.outputs.string}}.zip
    asset_content_type: application/zip