-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
ci: add workflow file for updating docs in website #258
Conversation
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.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
@asyncapi/bounty_team |
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.
https://deploy-preview-3126--asyncapi-website.netlify.app/docs/reference/bindings gives 404 as there needs to be index.md
added manually to website like https://github.com/asyncapi/website/blob/master/markdown/docs/reference/extensions/index.md. You can copy first paragraph from https://www.asyncapi.com/docs/concepts/asyncapi-document/adding-bindings (no need to duplicate - can do fragment https://github.com/asyncapi/website/tree/master/assets/docs/fragments) nad like in case of extensions, you can link to bindings repo.
sns and sqs are broken -> https://deploy-preview-3126--asyncapi-website.netlify.app/docs/reference/bindings/sns
async function processMarkdownFiles(folderPath, isRoot = true) { | ||
const items = await fs.readdir(folderPath, { withFileTypes: true }); | ||
for (const item of items) { | ||
const fullPath = path.join(folderPath, item.name); | ||
if (item.isDirectory()) { | ||
// Always process subdirectories, mark isRoot as false for recursive calls | ||
await processMarkdownFiles(fullPath, false); | ||
} else if (item.name.endsWith('.md') && !isRoot) { // Skip root level .md files | ||
const baseName = path.basename(fullPath, '.md'); | ||
const parentDirName = path.basename(folderPath); | ||
const newFileName = `${parentDirName}.md`; | ||
const newFullPath = path.join(folderPath, newFileName); | ||
await fs.rename(fullPath, newFullPath); | ||
|
||
const newData = `---\ntitle: '${parentDirName.charAt(0).toUpperCase() + parentDirName.slice(1)}'\nweight: ${itemIndex}\n---\n\n`; | ||
let existingFileData = await fs.readFile(newFullPath, 'utf8'); | ||
|
||
existingFileData = existingFileData.replace(/<img\s+src="(?!http)(.*?)"/g, (match, src) => { | ||
// Remove './' prefix from src path and prepend '/img/docs/' | ||
const updatedSrc = src.replace(/^\.\//, ''); | ||
return `<img src="/img/docs/${updatedSrc}"`; | ||
}); | ||
|
||
const updatedContent = newData + existingFileData; | ||
await fs.writeFile(newFullPath, updatedContent); | ||
itemIndex++; | ||
} | ||
} | ||
} | ||
|
||
await processMarkdownFiles(rootPath); |
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.
what is the reason for wrapping the code in async function that you later trigger anyway?
lemme know if you need some help |
Hey @derberg this is the test run I did for the above workflow run in the website - asyncapi/website#3179. Also, PR for adding index.md in the website has been opened - asyncapi/website#3180. Kindly review it. |
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.
2 small things
also left comment in asyncapi/website#3180 (comment)
@derberg Up for review |
@@ -37,7 +37,7 @@ jobs: | |||
uses: actions/github-script@v4 | |||
with: | |||
script: | | |||
const { writeFile } = require('fs').promises; | |||
const { writeFile } = require('fs').promis; |
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.
why promis
? should be promises
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.
Thanks for pointing it out. Resolved it.
merging, PR opened since July, other code owners could have a look - no need to wait for them as changes to bindings file were purely bug fix to markdown syntax |
Description
Draft PR to add github action to the bindings, for updating the docs inside AsyncAPI website.
Related issue(s)
Resolves #251