feat: docs automation for website #1
Workflow file for this run
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
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 Community documentation | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
steps: | ||
- name: Checkout Current repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: community | ||
- 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-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: | | ||
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(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(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 }}" |