-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat(GHA): add req header containing file URL #735
Conversation
... into separate functions
it's failing now but not sure why 😬
...payload, | ||
}), | ||
}) | ||
fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend hiding whitespace before reviewing the changes in this file!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing really to note except for what Jon's already mentioned. The new headers sound potentially pretty useful, thanks for thinking of them.
Co-Authored-By: Ryan Park <[email protected]>
🧰 Changes
tl;dr we're adding two new request headers when hitting the ReadMe API! This will facilitate some upcoming changes (see RM-5907) 👀
Here are the two new request headers:
x-rdme-ci
: if the command is being run in a CI environment, this will be set to the name of the CI environment as determined byci-info
(e.g.,GitHub Actions
1)x-readme-source-url
: if the command is syncing an OpenAPI or Markdown doc to ReadMe, this header2 contains the source URL for the file (if applicable). There are two ways that we determine the source file:openapi
command is being run and the file in question is located at an external URL3, that URL is used.As expected, a bunch of other stuff was done in this PR to facilitate these changes:
ci-info
— it continues to be very annoying to write tests with and we should confine all usage of the package to our helper functions insrc/lib/isCI.ts
.oas-normalize
(see fix: stricter type oas-normalize#248)🧬 QA & Testing
Well since each of these CI runs hit the ReadMe API to update this test project's reference docs, I was able to go into our Metrics dashboard for the ReadMe API and confirm that the request headers are showing up as expected:
If you go to the API Calls section in the dashboard, filter for my email address, and look for the
rdme-test
in the user column, you can click into any one of the API logs and peep the request headers. Note that the URL is off because we rely on unconventional checkout pathing logic in this workflow, but I feel good about these changes with the test coverage.Footnotes
See the full list here: https://github.com/watson/ci-info#supported-ci-tools (the Name column is what will be used) ↩
For commands like
docs
andopenapi
, we do a lot of GET requests as part of the general workflow, but this request header will only be added to thePOST
/PUT
requests that directly update Markdown/OpenAPI files. ↩For example,
rdme openapi https://github.com/readmeio/oas-examples/blob/main/3.0/json/petstore.json
↩