0

My workflow's script with action/github-script(v6) step:

const response = await github.request('POST https://example.com', {
  headers: {
    authorization: 'Bearer xxx',
    accept: 'application/vnd.heroku+json; version=3', // I want header to be like this
    'content-type': 'application/json'
  },
  // some other options, like request body...
});
console.log(response);

When the accept and other HTTP headers are automatically overriden with:

{
  status: 400,
  reponse: {}, // not important, body complains about incorrect Accept header
  request: {
    method: 'POST',
    url: 'example.com',
    headers: {
      accept: 'application/vnd.github.-preview+json', // wtf?
      authorization: 'token [REDACTED]', // wtf? it should start with "Bearer"
      'content-type': 'application/json', // ok, as expected
      'user-agent': 'actions/github-script octokit-core.js/3.5.1 Node.js/16.13.0 (linux; x64)' // ok, but I didn't set this...
    },
  // other stuff...
}

Now the question is what am I missing? Can I make truthly custom request using github.request() api like that?

3
  • For what I checked in this function, it overwrites the header using token instead of bearer depending on the condition. Regarding the accept header, it's always added by default to all request using the action (example in the Post function). The user-agent seems to be default as well depending on the request (L10529 in the same file) Commented Jun 30, 2022 at 14:48
  • Yup I saw that too, but I didn't found any solution to enforce custom headers. It feels clunky to use curl bash script for this... Commented Jul 1, 2022 at 6:07
  • I usually create my own scripts (generally using python) to perform this kind of operation. I feel more secure as an action tag can be updated without the users knowing. Commented Jul 1, 2022 at 11:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.