-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dca9022
Added workflow file for updating docs in website
akshatnema d471963
updated workflow
akshatnema 88566f2
Added new flows inside update-website-docs gh action
akshatnema c9f3ad9
updated ibmmq README
akshatnema b182f5f
minor tweaks for workflow
akshatnema 2bdfa16
updated br tag in docs
akshatnema 0459e30
Resolved errors for sqs and sns
akshatnema 4a066f6
removed .idea folder
akshatnema b60de07
updated workflow
akshatnema 3b773a9
updated workflow
akshatnema fc0ec93
reverted previous change
akshatnema e794c25
Merge branch 'master' into update-docs-website
akshatnema 02d730f
Added changes according to review
akshatnema 46060fa
minor fixes
akshatnema e950b15
Update update-docs-in-website.yml
derberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Update latest Bindings documentation in the website | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "**/*.md" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Make-PR: | ||
name: Make PR on website repository with updated latest Bindings documentation | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
steps: | ||
- name: Checkout Current repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: bindings | ||
- name: Checkout Another repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: asyncapi/website | ||
path: website | ||
token: ${{ env.GITHUB_TOKEN }} | ||
- name: Config git | ||
run: | | ||
git config --global user.name asyncapi-bot | ||
git config --global user.email [email protected] | ||
- name: Create branch | ||
working-directory: ./website | ||
run: | | ||
git checkout -b update-bindings-docs-${{ github.sha }} | ||
- name: Update edit-page-config.json | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const { writeFile } = require('fs').promis; | ||
const configPath = './website/config/edit-page-config.json'; | ||
const checkSlug = 'reference/bindings/'; | ||
const slug = { | ||
"value": checkSlug, | ||
"href": "https://github.com/asyncapi/bindings/tree/master" | ||
derberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
const configData = require(configPath); | ||
const entryExists = configData.some(entry => entry.value === checkSlug); | ||
if (!entryExists) { | ||
configData.unshift(slug); | ||
await writeFile(configPath, JSON.stringify(configData, null, 2)) | ||
} | ||
|
||
- name: Update title and weight of the markdown files | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const rootPath = './bindings/'; | ||
let itemIndex = 10; | ||
|
||
function processMarkdownFiles(folderPath, isRoot = true) { | ||
const items = fs.readdirSync(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 | ||
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); | ||
fs.renameSync(fullPath, newFullPath); | ||
|
||
const newData = `---\ntitle: '${parentDirName}'\nweight: ${itemIndex}\n---\n\n`; | ||
let existingFileData = fs.readFileSync(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; | ||
fs.writeFileSync(newFullPath, updatedContent); | ||
itemIndex++; | ||
} | ||
} | ||
} | ||
|
||
await processMarkdownFiles(rootPath); | ||
|
||
- name: Copy bindings folder from Current Repo to Another | ||
working-directory: ./website | ||
run: | | ||
mkdir -p ./markdown/docs/reference/bindings | ||
printf "%s\ntitle: Bindings\nweight: 11\n%s" "---" "---"> ../bindings/_section.md | ||
find ../bindings -type f -name '*.md' ! -name 'CONTRIBUTING.md' ! -name 'README.md' ! -name 'CODE_OF_CONDUCT.md' -exec mv {} ./markdown/docs/reference/bindings/ \; | ||
|
||
- name: Copy images to website | ||
run: | | ||
# Assuming the workflow runs on Linux/macOS | ||
# Create the target directory if it doesn't exist | ||
mkdir -p ./website/public/img/docs/ | ||
# Find and copy all image files from the source directory to the target directory | ||
find ./bindings/ -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" -iname "*.webp" \) -exec cp {} ./website/public/img/docs/ \; | ||
|
||
- name: Commit and push | ||
working-directory: ./website | ||
run: | | ||
git add . | ||
git commit -m "docs(extension): update latest bindings docs" | ||
git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website | ||
|
||
- name: Create PR | ||
working-directory: ./website | ||
run: | | ||
gh pr create --title "docs(bindings): update latest bindings documentation" --body "Updated bindings documentation is available and this PR introduces update to bindings folder on the website" --head "update-bindings-docs-${{ github.sha }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 bepromises
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.