1

I'm trying to do a GitHub action that need to upload an artifact

But since I'm already in an action I can't call actions/upload-artifact@v2
There are some answer that suggest downloading the action in mine but this one is in JS and mine in shell.
Also the GitHub API doesn't give any result on how to upload one (only download, list or delete)

Therefore my question is: Is there a way to upload an artifact to GitHub from a shell script?

Xwilarg
  • 364
  • 1
  • 6
  • 16
  • Although the endpoints for uploading are not documented, they can be extracted from the source code for the *upload-artifact* action https://github.com/actions/toolkit/blob/4bf916289e5e32bb7d1bd7f21842c3afeab3b25a/packages/artifact/src/internal/upload-http-client.ts#L40. Then use *curl* or something similar to hit the endpoints with the data. – riQQ Apr 13 '21 at 22:28

1 Answers1

1

You can share data between steps. For example, you can have your action in the first step and then on the second step, upload the results.

Check this answer for more details.

If you want to add the ability to upload artifacts directly to your action you should use the GitHub API.

If the action is implemented in JavaScript there is a library from GitHub that can be used - toolkit/artifact

For shell script, I am not aware how to do that.

Denis Duev
  • 513
  • 3
  • 5
  • I guess that works if I'm in a workflow but in an action I have a yml that lauch a Docker which use my shell script, not sure if I can do many steps there – Xwilarg Apr 13 '21 at 12:21
  • Just making another comment to follow your edit: I didn't know about the JS library, I would have like to use shell but I'll probably fall back on this if I find no solution – Xwilarg Apr 13 '21 at 12:25
  • As you have said I didn't find and Endpoint for uploading artifacts. I am not exactly sure how it is implemented in the toolkit library, but it is not a simple call to an endpoint. If the action is implemented in JavaScript it is quite easy to [upload files](https://github.com/actions/toolkit/tree/main/packages/artifact#example-using-absolute-file-paths) – Denis Duev Apr 13 '21 at 12:37