Update Docs #41
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 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 }} |