Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support file uploads #32

Open
asmeurer opened this issue Sep 19, 2022 · 4 comments
Open

Support file uploads #32

asmeurer opened this issue Sep 19, 2022 · 4 comments

Comments

@asmeurer
Copy link

I want to write an action that produces data that gets submitted to a webhook by workflows, but the data in general is too large to put in an action output (GitHub Actions produces an "out of memory" error). It would be useful to be able to upload a file to the webhook. I believe this can be done with curl using the -F flag (see https://everything.curl.dev/http/multipart#file-input).

@distributhor
Copy link
Owner

I'll have a look at this option and how it can be incorporated

@distributhor
Copy link
Owner

Hi. I am trying to understand the use case you have. Currently the call to the webhook will post some data to it (either JSON or form urlencoded). The file would presumably be generated by the GIthub action when it's run? And then it must be sent as an additional input along with the current data? If you can elaborate a bit it will help me determine the best course of action.

@asmeurer
Copy link
Author

I'll prefix this by saying I'm not an expert at GitHub Actions, so it's quite possible there's a better way to do what I'm trying to do.

We are trying to build a reusable Action that people can run that will run a test suite and upload the results (as a JSON file) to a server. This JSON file can be large (~10 MB) as it contains information about all the tests, especially if there are many test failures. The way I am implementing this is to have a reusable action repo, which is a composite action) that has all the logic for running the tests, getting the JSON file, etc. Then the users who will run this action will create a action file that references this action and gives it the appropriate inputs. Unfortunately, as far as I can tell, the actual workflow-webhook part of the action has to go in this end-user workflow file, because if you put it in the composite action, it cannot access the secret variables (which would be different for each workflow). Ideally I'd like to make the logic that goes in the workflow files as minimal as possible so that if we need to update the composite action we won't have to go and update very individual workflow file.

My initial attempt was to send the JSON blob through as an output of the composite action, but this failed because GitHub Actions gave a "maximum allowed memory size was exceeded" error.

@ranma2913
Copy link

ranma2913 commented Apr 3, 2024

This action is really best when you want to forward simple data or the github event payload.

For your use-case, could just have a shell step where you run your own CURL commands like this action does:

# initial workflow steps
- name: Upload Json
  shell: bash
  run: |
    curl -X POST "https://myhost.com/my/path" --data "@path/of/file.json"
# later workflow steps

See: https://docs.github.com/en/actions/learn-github-actions/essential-features-of-github-actions#adding-scripts-to-your-workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants