Skip to content

github.request() should respect custom headers like Accept, Authorization etc. #272

Open
@tlenex

Description

@tlenex

Is your feature request related to a problem? Please describe.
I'd like to make custom, external request with custom headers for fetching data using github.request() in my github-script.
However, the method is ignoring custom HTTP headers provided in it's options like Accept and Authorization - I didn't check any others User-agent might also be the case.

Describe the solution you'd like
Script like this:

github.request('POST https://example.com', {
  // I want headers to be like this:
  headers: {
    authorization: 'Bearer xxx',
    accept: 'application/vnd.heroku+json; version=3',
    'content-type': 'application/json'
  }
});

Could respect given headers in the request options.
It would be a really nice way of fetching data in github-script without usage of additional steps/libs/dependencies.

Describe alternatives you've considered
Using bash step with curl or exec.exec('curl'); in github-script step, but both feel clunky in this case. Installing node deps like node-fetch seems like a waste of time and resources, especially when github.request() is using exactly node-fetch under the hood, but we just can't access it.

Additional context
https://stackoverflow.com/questions/72815672/cant-override-some-http-headers-with-github-request-in-actions-github-script

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions