Skip to content

Update Docs

Update Docs #41

Workflow file for this run

name: Update Docs
on:
workflow_dispatch:
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout ๐Ÿ›Ž๏ธ
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
path: main
- name: Checkout origin repo ๐Ÿ›Ž๏ธ
uses: actions/checkout@v3
with:
repository: guoxianzhe/docs
ref: main
path: "remote-repo"
# token: ${{ secrets.AGORAIO_ACCESS_TOKEN }}
- name: Install pnpm ๐Ÿค๐Ÿป
uses: pnpm/[email protected]
with:
version: latest
- name: Setup Node ๐Ÿ’š
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
cache-dependency-path: "./main/pnpm-lock.yaml"
- name: Update Docs ๐Ÿ“–
working-directory: "./main"
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git fetch
if git rev-parse --verify origin/doc/${{ github.ref_name }}-update-doc >/dev/null 2>&1
then
git switch doc/${{ github.ref_name }}-update-doc
else
git switch -c doc/${{ github.ref_name }}-update-doc
echo "CREATE_PR=1" >> "$GITHUB_ENV"
fi
cp ../remote-repo/docs-api-reference/rtc/react-sdk/hooks.react.mdx packages/agora-rtc-react/docs/hooks.mdx
cp ../remote-repo/docs-api-reference/rtc/react-sdk/_hooks-en.react.mdx packages/agora-rtc-react/docs/hooks-en.mdx
cp ../remote-repo/docs-api-reference/rtc/react-sdk/components.react.mdx packages/agora-rtc-react/docs/components.mdx
cp ../remote-repo/docs-api-reference/rtc/react-sdk/_components-en.react.mdx packages/agora-rtc-react/docs/components-en.mdx
cp ../remote-repo/docs-api-reference/rtc/react-sdk/data-types.react.mdx packages/agora-rtc-react/docs/data-types.mdx
cp ../remote-repo/docs-api-reference/rtc/react-sdk/_data-types-en.react.mdx packages/agora-rtc-react/docs/data-types-en.mdx
rm -rf ../remote-repo
pnpm install
pnpm gene-docs
pnpm run lint:fix
if git diff --quiet;
then
echo "No changes, no need to update docs";
else
git add .
git commit -m "docs: update doc"
git push origin doc/${{ github.ref_name }}-update-doc
fi
- name: Create Pull Request ๐Ÿ“
working-directory: "./main"
if: env.CREATE_PR == 1
run: |
gh pr create -B ${{ github.ref_name }} -H doc/${{ github.ref_name }}-update-doc --title '[AUTO] ๐Ÿ“–update docs' --body 'Created by Github action' --label 'ci:doc-update'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}