1+ name : Update latest Community documentation in the website
2+
3+ on :
4+ push :
5+ branches :
6+ - ' master'
7+ paths :
8+ - ' docs/*.md'
9+
10+ jobs :
11+ Make-PR :
12+ name : Make PR on website repository with updated latest Community documentation
13+ runs-on : ubuntu-latest
14+ env :
15+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
16+ steps :
17+ - name : Checkout Current repository
18+ uses : actions/checkout@v4
19+ with :
20+ path : community
21+ - name : Checkout Another repository
22+ uses : actions/checkout@v4
23+ with :
24+ repository : asyncapi/website
25+ path : website
26+ token : ${{ env.GITHUB_TOKEN }}
27+ - name : Config git
28+ run : |
29+ git config --global user.name asyncapi-bot
30+ git config --global user.email info@asyncapi.io
31+ - name : Create branch
32+ working-directory : ./website
33+ run : |
34+ git checkout -b update-community-docs-${{ github.sha }}
35+ - name : Update edit-page-config.json
36+ uses : actions/github-script@v4
37+ with :
38+ script : |
39+ const fs = require('fs').promises;
40+ const configPath = './website/config/edit-page-config.json';
41+ const configData = require(configPath);
42+ const docsDir = 'community/docs';
43+
44+ async function readDirectories(dirPath) {
45+ const entries = await fs.readdir(dirPath, { withFileTypes: true });
46+ const subdirectories = entries.filter(entry => entry.isDirectory()).map(entry => entry.name);
47+ return subdirectories;
48+ }
49+
50+ async function updateConfigData() {
51+ const subfolders = await readDirectories(docsDir);
52+
53+ for (const subfolder of subfolders) {
54+ const checkSlug = `community/${subfolder}`;
55+ const slug = {
56+ "value": checkSlug,
57+ "href": `https://github.com/asyncapi/community/tree/master/docs/${subfolder}`
58+ };
59+
60+ const entryExists = configData.some(entry => entry.value === checkSlug);
61+ if (!entryExists) {
62+ configData.push(slug);
63+ }
64+ }
65+
66+ await fs.writeFile(configPath, JSON.stringify(configData, null, 2));
67+ }
68+ updateConfigData();
69+
70+ - name : Copy community folder from Current Repo to Another
71+ working-directory : ./website
72+ run : |
73+ rm -r ./markdown/docs/community/onboarding-guide
74+ mkdir -p ./markdown/docs/community/onboarding-guide
75+ rm ../community/docs/README.md
76+ mv ./community/docs/* ./markdown/docs/community/
77+ - name : Commit and push
78+ working-directory : ./website
79+ run : |
80+ git add .
81+ git commit -m "docs(community): update latest community docs"
82+ git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website
83+ - name : Create PR
84+ working-directory : ./website
85+ run : |
86+ 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 }}"
0 commit comments