demo test #11
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: Deploy the docs to RTD | ||
on: | ||
push: | ||
branches: [ main ] | ||
paths: # 当更改以下文件时,会触发Actions更新文档 | ||
- 'rapid_videocr/**' | ||
- '.github/workflows/deploy_docs_to_rtd.yml' | ||
- 'README.md' | ||
env: | ||
REPO_SSH: git@github.com:SWHL/RapidVideOCR.git | ||
CLONE_URL: ${{ github.event.repository.clone_url }} | ||
USER_NAME: ${{ github.event.repository.owner.name }} | ||
USER_EMAIL: ${{ github.event.repository.owner.email }} | ||
SUBMMIT_BRANCH: docs | ||
PACKAGE_NAME: rapid_videocr | ||
jobs: | ||
Deploy_TO_RTD: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.7' | ||
architecture: 'x64' | ||
- name: Set SSH Environment | ||
env: | ||
DEPLOY_KEYS: ${{ secrets.DEPLOY_KEYS }} | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
echo "$DEPLOY_KEYS" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
chmod 700 ~/.ssh && chmod 600 ~/.ssh/* | ||
git config --global user.name $USER_NAME | ||
git config --global user.email $USER_EMAIL | ||
- name: Summit repo to docs branch. | ||
run: | | ||
ls | ||
rm -r docs | ||
git clone -b ${SUBMMIT_BRANCH} $CLONE_URL ${SUBMMIT_BRANCH} | ||
cd ${SUBMMIT_BRANCH} | ||
rm -r ${PACKAGE_NAME} || true | ||
rm source/README.md || true | ||
echo "=====================" | ||
echo ${SUBMMIT_BRANCH} | ||
cp -r ../${PACKAGE_NAME} . | ||
echo "Update requirements and add packages needed by sphinx" | ||
echo -e '\nsphinx_rtd_theme\nsphinxcontrib.mermaid\nmyst-parser\nsphinx_copybutton\nget_pypi_latest_version' >> ../requirements.txt | ||
rm requirements.txt | ||
cp ../requirements.txt . | ||
echo "replace mermaid to {mermaid}" | ||
sed -i 's/mermaid/{mermaid}/g' ../README.md | ||
cp ../README.md source/ | ||
echo "Generate the api doc" | ||
pip install sphinx | ||
sphinx-apidoc -o source/API/ ./${PACKAGE_NAME} -f -E -M | ||
sed -i '1d' source/API/modules.rst | ||
sed -i '1i\API' source/API/modules.rst | ||
git add . | ||
git status | ||
git remote remove origin | ||
git remote add origin ${REPO_SSH} | ||
git commit -m 'Actions auto update' && git push -f origin ${SUBMMIT_BRANCH} || echo "No changes to commit" | ||
作者:SWHL | ||
链接:https://juejin.cn/post/7217295157706719290 | ||
来源:稀土掘金 | ||
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 |