From bbf408ff2c13665277dde9247d55b547112f19c1 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 1 Mar 2024 00:17:17 +0530 Subject: [PATCH 01/12] add initial script --- .github/workflows/update-docs-in-website.yml | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/update-docs-in-website.yml diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml new file mode 100644 index 000000000..595e8cb90 --- /dev/null +++ b/.github/workflows/update-docs-in-website.yml @@ -0,0 +1,50 @@ +name: Update latest Community documentation in the website + +on: + push: + branches: + - 'master' + paths: + - 'docs/*.md' + +jobs: + Make-PR: + name: Make PR on website repository with updated latest CLI documentation + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + steps: + - name: Checkout Current repository + uses: actions/checkout@v3 + with: + path: cli + - name: Checkout Another repository + uses: actions/checkout@v3 + 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 info@asyncapi.io + - name: Create branch + working-directory: ./website + run: | + git checkout -b update-cli-docs-${{ github.sha }} + - name: Copy cli folder from Current Repo to Another + working-directory: ./website + run: | + mkdir -p ./pages/docs/tools/cli + printf "%s\ntitle: CLI\nweight: 10\n%s" "---" "---"> ../cli/docs/_section.md + mv ../cli/docs/*.md ./pages/docs/tools/cli + - name: Commit and push + working-directory: ./website + run: | + git add . + git commit -m "docs(cli): update latest cli docs" + git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website + - name: Create PR + working-directory: ./website + run: | + gh pr create --title "docs(cli): update latest cli documentation" --body "Updated cli documentation is available and this PR introduces update to cli folder on the website" --head "update-cli-docs-${{ github.sha }}" \ No newline at end of file From 9982a1e15c37644f511265304aea7a23f4e1c950 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 1 Mar 2024 00:43:32 +0530 Subject: [PATCH 02/12] modify workflow code --- .github/workflows/update-docs-in-website.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 595e8cb90..376d82190 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -9,7 +9,7 @@ on: jobs: Make-PR: - name: Make PR on website repository with updated latest CLI documentation + name: Make PR on website repository with updated latest Community documentation runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -17,7 +17,7 @@ jobs: - name: Checkout Current repository uses: actions/checkout@v3 with: - path: cli + path: community - name: Checkout Another repository uses: actions/checkout@v3 with: @@ -31,20 +31,20 @@ jobs: - name: Create branch working-directory: ./website run: | - git checkout -b update-cli-docs-${{ github.sha }} - - name: Copy cli folder from Current Repo to Another + git checkout -b update-community-docs-${{ github.sha }} + - name: Copy community folder from Current Repo to Another working-directory: ./website run: | - mkdir -p ./pages/docs/tools/cli - printf "%s\ntitle: CLI\nweight: 10\n%s" "---" "---"> ../cli/docs/_section.md - mv ../cli/docs/*.md ./pages/docs/tools/cli + mkdir -p ./pages/docs/community/ + printf "%s\ntitle: Community\nweight: 7\n%s" "---" "---"> ../community/docs/_section.md + mv ../community/docs/*.md ./pages/docs/community - name: Commit and push working-directory: ./website run: | git add . - git commit -m "docs(cli): update latest cli docs" + git commit -m "docs(community): update latest community docs" git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website - name: Create PR working-directory: ./website run: | - gh pr create --title "docs(cli): update latest cli documentation" --body "Updated cli documentation is available and this PR introduces update to cli folder on the website" --head "update-cli-docs-${{ github.sha }}" \ No newline at end of file + gh pr create --title "docs(community): update latest community documentation" --body "Updated community documentation is available and this PR introduces update to community folder on the website" --head "update-community-docs-${{ github.sha }}" \ No newline at end of file From 98aed91df599d8a63283af87bdac1c3ff3f67a74 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 1 Mar 2024 11:38:09 +0530 Subject: [PATCH 03/12] update `checkout` action version --- .github/workflows/update-docs-in-website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 376d82190..acff53a97 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -15,11 +15,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - name: Checkout Current repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: community - name: Checkout Another repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: asyncapi/website path: website From 8ad48e3e936ce52b41e2f916a19bff8601aed8dc Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Thu, 7 Mar 2024 11:51:47 +0530 Subject: [PATCH 04/12] fix: add script for `edit-page-config` Changes: - added the script section from here: https://github.com/asyncapi/extensions-catalog/blob/7270922048f71b035d02d7dea950e642e2160dcc/.github/workflows/update-extensions-in-website.yml#L36C9-L54C1 --- .github/workflows/update-docs-in-website.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index acff53a97..1445fbd1c 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -32,6 +32,24 @@ jobs: working-directory: ./website run: | git checkout -b update-community-docs-${{ github.sha }} + - name: Update edit-page-config.json + uses: actions/github-script@v4 + with: + script: | + const { writeFile } = require('fs').promises; + const configPath = './website/config/edit-page-config.json'; + const checkSlug = 'reference/extensions/'; + const slug = { + "value": checkSlug, + "href": "https://github.com/asyncapi/community/tree/master/docs" + }; + + const configData = require(configPath); + const entryExists = configData.some(entry => entry.value === checkSlug); + if (!entryExists) { + configData.push(slug); + await writeFile(configPath, JSON.stringify(configData, null, 2)) + } - name: Copy community folder from Current Repo to Another working-directory: ./website run: | From eb9ea898c3f3cbe12d78c80c186b37f81b8d1fbb Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Thu, 7 Mar 2024 12:12:22 +0530 Subject: [PATCH 05/12] chore: fix wrong indentation in the YAML file --- .github/workflows/update-docs-in-website.yml | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 1445fbd1c..a5244b9c8 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -33,23 +33,23 @@ jobs: run: | git checkout -b update-community-docs-${{ github.sha }} - name: Update edit-page-config.json - uses: actions/github-script@v4 - with: - script: | - const { writeFile } = require('fs').promises; - const configPath = './website/config/edit-page-config.json'; - const checkSlug = 'reference/extensions/'; - const slug = { - "value": checkSlug, - "href": "https://github.com/asyncapi/community/tree/master/docs" - }; - - const configData = require(configPath); - const entryExists = configData.some(entry => entry.value === checkSlug); - if (!entryExists) { - configData.push(slug); - await writeFile(configPath, JSON.stringify(configData, null, 2)) - } + uses: actions/github-script@v4 + with: + script: | + const { writeFile } = require('fs').promises; + const configPath = './website/config/edit-page-config.json'; + const checkSlug = 'reference/extensions/'; + const slug = { + "value": checkSlug, + "href": "https://github.com/asyncapi/community/tree/master/docs" + }; + + const configData = require(configPath); + const entryExists = configData.some(entry => entry.value === checkSlug); + if (!entryExists) { + configData.push(slug); + await writeFile(configPath, JSON.stringify(configData, null, 2)) + } - name: Copy community folder from Current Repo to Another working-directory: ./website run: | From 2edb616d14e8357637c2b050bd3ecd8d66a9d8dd Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Thu, 14 Mar 2024 10:32:10 +0530 Subject: [PATCH 06/12] update `checkSlug` suggestion applies from: https://github.com/asyncapi/community/pull/1082#discussion_r1524163260 Co-authored-by: Sambhav Gupta <81870866+sambhavgupta0705@users.noreply.github.com> --- .github/workflows/update-docs-in-website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index a5244b9c8..b30106015 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -38,7 +38,7 @@ jobs: script: | const { writeFile } = require('fs').promises; const configPath = './website/config/edit-page-config.json'; - const checkSlug = 'reference/extensions/'; + const checkSlug = 'community/docs'; const slug = { "value": checkSlug, "href": "https://github.com/asyncapi/community/tree/master/docs" From 768c2b24341438dfc38bb07f6363bea766c191d0 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:21:41 +0530 Subject: [PATCH 07/12] Update script applied suggestion from: https://github.com/asyncapi/community/pull/1082#discussion_r1529106026 Co-authored-by: Lukasz Gornicki --- .github/workflows/update-docs-in-website.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index b30106015..676c560d7 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -53,7 +53,9 @@ jobs: - name: Copy community folder from Current Repo to Another working-directory: ./website run: | - mkdir -p ./pages/docs/community/ + rm -r ./pages/docs/community/onboarding-guide + mkdir -p ./pages/docs/community/onboarding-guide + rm ../community/docs/README.md printf "%s\ntitle: Community\nweight: 7\n%s" "---" "---"> ../community/docs/_section.md mv ../community/docs/*.md ./pages/docs/community - name: Commit and push From a70dab566fdb60ca9e85cd87a2b895194505a0b7 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:27:16 +0530 Subject: [PATCH 08/12] Update script Co-authored-by: Lukasz Gornicki --- .github/workflows/update-docs-in-website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 676c560d7..59334dcf5 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -56,7 +56,7 @@ jobs: rm -r ./pages/docs/community/onboarding-guide mkdir -p ./pages/docs/community/onboarding-guide rm ../community/docs/README.md - printf "%s\ntitle: Community\nweight: 7\n%s" "---" "---"> ../community/docs/_section.md + printf "%s\ntitle: Onboarding guide\nweight: 10\n%s" "---" "---"> ../community/docs/onboarding-guide/_section.md mv ../community/docs/*.md ./pages/docs/community - name: Commit and push working-directory: ./website From 7982022f75bef0b195400380acd2c75f76458953 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:27:59 +0530 Subject: [PATCH 09/12] Update script https://github.com/asyncapi/community/pull/1082#discussion_r1529128578 Co-authored-by: Lukasz Gornicki --- .github/workflows/update-docs-in-website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 59334dcf5..e64f41c3e 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -57,7 +57,7 @@ jobs: mkdir -p ./pages/docs/community/onboarding-guide rm ../community/docs/README.md printf "%s\ntitle: Onboarding guide\nweight: 10\n%s" "---" "---"> ../community/docs/onboarding-guide/_section.md - mv ../community/docs/*.md ./pages/docs/community + mv ../community/docs/onboarding-guide/*.md ./pages/docs/community/onboarding-guide - name: Commit and push working-directory: ./website run: | From 7e3d25fe81c6621449668688963fa73d60a83a4c Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:28:21 +0530 Subject: [PATCH 10/12] Update script https://github.com/asyncapi/community/pull/1082#discussion_r1529158749 Co-authored-by: Lukasz Gornicki --- .github/workflows/update-docs-in-website.yml | 35 +++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index e64f41c3e..9a79196d1 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -36,20 +36,37 @@ jobs: uses: actions/github-script@v4 with: script: | - const { writeFile } = require('fs').promises; - const configPath = './website/config/edit-page-config.json'; - const checkSlug = 'community/docs'; + const fs = require('fs').promises; + const configPath = './website/config/edit-page-config.json'; + const configData = require(configPath); + const docsDir = 'community/docs'; + + async function readDirectories(dirPath) { + const entries = await fs.readdir(dirPath, { withFileTypes: true }); + const subdirectories = entries.filter(entry => entry.isDirectory()).map(entry => entry.name); + return subdirectories; + } + + async function updateConfigData() { + const subfolders = await readDirectories(docsDir); + + for (const subfolder of subfolders) { + const checkSlug = `community/${subfolder}`; const slug = { - "value": checkSlug, - "href": "https://github.com/asyncapi/community/tree/master/docs" + "value": checkSlug, + "href": `https://github.com/asyncapi/community/tree/master/docs/${subfolder}` }; - - const configData = require(configPath); + const entryExists = configData.some(entry => entry.value === checkSlug); if (!entryExists) { - configData.push(slug); - await writeFile(configPath, JSON.stringify(configData, null, 2)) + configData.push(slug); } + } + + await fs.writeFile(configPath, JSON.stringify(configData, null, 2)); + } + + updateConfigData(); - name: Copy community folder from Current Repo to Another working-directory: ./website run: | From cd6a986e27a3194392e6ed7ce39e95ec7f3d9382 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:29:51 +0530 Subject: [PATCH 11/12] chore: fix indentation --- .github/workflows/update-docs-in-website.yml | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 9a79196d1..941c334f9 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -39,32 +39,32 @@ jobs: const fs = require('fs').promises; const configPath = './website/config/edit-page-config.json'; const configData = require(configPath); - const docsDir = 'community/docs'; - - async function readDirectories(dirPath) { - const entries = await fs.readdir(dirPath, { withFileTypes: true }); - const subdirectories = entries.filter(entry => entry.isDirectory()).map(entry => entry.name); - return subdirectories; - } - - async function updateConfigData() { - const subfolders = await readDirectories(docsDir); - - for (const subfolder of subfolders) { - const checkSlug = `community/${subfolder}`; - const slug = { - "value": checkSlug, - "href": `https://github.com/asyncapi/community/tree/master/docs/${subfolder}` - }; - - const entryExists = configData.some(entry => entry.value === checkSlug); - if (!entryExists) { - configData.push(slug); - } - } - - await fs.writeFile(configPath, JSON.stringify(configData, null, 2)); - } + const docsDir = 'community/docs'; + + async function readDirectories(dirPath) { + const entries = await fs.readdir(dirPath, { withFileTypes: true }); + const subdirectories = entries.filter(entry => entry.isDirectory()).map(entry => entry.name); + return subdirectories; + } + + async function updateConfigData() { + const subfolders = await readDirectories(docsDir); + + for (const subfolder of subfolders) { + const checkSlug = `community/${subfolder}`; + const slug = { + "value": checkSlug, + "href": `https://github.com/asyncapi/community/tree/master/docs/${subfolder}` + }; + + const entryExists = configData.some(entry => entry.value === checkSlug); + if (!entryExists) { + configData.push(slug); + } + } + + await fs.writeFile(configPath, JSON.stringify(configData, null, 2)); + } updateConfigData(); - name: Copy community folder from Current Repo to Another From e8794d47b422ed2b386992f67dc65c4b534c07e5 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Fri, 5 Apr 2024 12:38:16 +0530 Subject: [PATCH 12/12] chore: small indent fix --- .github/workflows/update-docs-in-website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-docs-in-website.yml b/.github/workflows/update-docs-in-website.yml index 941c334f9..a72ebf4bc 100644 --- a/.github/workflows/update-docs-in-website.yml +++ b/.github/workflows/update-docs-in-website.yml @@ -65,8 +65,8 @@ jobs: await fs.writeFile(configPath, JSON.stringify(configData, null, 2)); } - - updateConfigData(); + updateConfigData(); + - name: Copy community folder from Current Repo to Another working-directory: ./website run: |