1

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...)

ekolis
  • 6,270
  • 12
  • 50
  • 101
  • What is `FrEee.WinForms-cc1b19f204`? _Is_ it a directory? – Edward Thomson Jan 30 '21 at 23:25
  • It's the name of the artifact that I'm trying to package as an asset. I'll edit my post to provide more of the actions as context. – ekolis Feb 02 '21 at 02:24
  • I just want to know what is on the filesystem. You say it’s a zip file, but the name doesn’t it end in `.zip`? What’s the output of `ls -FlasR`? – Edward Thomson Feb 02 '21 at 09:57
  • I think I might understand what you’re trying to do? Are you running the upload-artifact step and trying to upload the zip that _it creates_ as a release asset? – Edward Thomson Feb 02 '21 at 10:05
  • Yes, I am trying to upload an artifact, then upload the artifact as a release asset. For whatever reason I had to download the artifact that I'd just uploaded in order for it to be visible to the upload-release-asset action; let me add that action too. – ekolis Feb 04 '21 at 02:29
  • On the filesystem? I have no idea, this is on GitHub and I wish I knew how to get a listing of what's on the filesystem, that would make my life so much easier! – ekolis Feb 04 '21 at 02:29

1 Answers1

2

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
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • Wait, you can run shell commands as part of a job? That would definitely be handy! My job is running on a Windows server so I suppose I'd want to use `dir` instead of `ls`, but thanks! – ekolis Feb 08 '21 at 15:31