-
Notifications
You must be signed in to change notification settings - Fork 2
82 lines (67 loc) · 2.52 KB
/
deploy_docs_to_rtd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。