Skip to content

Commit 87a35a9

Browse files
Working on CI for doc deployment.
1 parent 2a037d4 commit 87a35a9

File tree

3 files changed

+69
-9
lines changed

3 files changed

+69
-9
lines changed

.ci/build_site.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ readonly MODULE_TITLE_LOCATION='<section class="module-info">'
2121
readonly API_DOC_MARKER='<!-- API-DOC-MARKER -->'
2222

2323
function check_git() {
24-
# TEST
25-
return 0
26-
27-
if [ ! -z "$(git status --porcelain)" ] ; then
24+
if [ ! -z "$(git status --porcelain)" ] ; then
2825
echo "ERROR: Repository is not clean."
2926
exit 1
3027
fi
3128

32-
if [ $(git branch --show-current) == 'main' ] ; then
29+
if [ $(git branch --show-current) != 'main' ] ; then
3330
echo "ERROR: Repository is not on the main branch."
3431
exit 2
3532
fi

.github/workflows/main.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,63 @@ jobs:
5353
if: runner.os == 'Linux'
5454
shell: bash
5555
run: ./scripts/gen_docs.sh
56+
57+
docs:
58+
needs: [test]
59+
if: ${{ github.event_name == 'push' && github.repository_owner == 'edulinq' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
60+
61+
permissions:
62+
contents: read
63+
pages: write
64+
id-token: write
65+
66+
environment:
67+
name: github-pages
68+
url: ${{ steps.deployment.outputs.page_url }}
69+
70+
strategy:
71+
matrix:
72+
python-version: ['3.11']
73+
os: ['ubuntu-24.04']
74+
75+
runs-on: ${{ matrix.os }}
76+
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
fetch-tags: true
83+
84+
- name: Set up Python ${{ matrix.python-version }}
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version: ${{ matrix.python-version }}
88+
89+
- name: Cache Python Dependencies
90+
uses: actions/cache@v4
91+
with:
92+
path: ${{ env.pythonLocation }}
93+
key: ${{ runner.os }}-os:${{ matrix.os }}-python:${{ matrix.python-version }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
94+
95+
- name: Install Dependencies
96+
shell: bash
97+
run: pip install -r requirements.txt -r requirements-dev.txt
98+
99+
- name: Setup Pages
100+
uses: actions/configure-pages@v5
101+
102+
- name: Build Site
103+
shell: bash
104+
run: |
105+
git checkout main
106+
./.ci/build_site.sh
107+
108+
- name: Upload Artifact
109+
uses: actions/upload-pages-artifact@v3
110+
with:
111+
path: '._site'
112+
113+
- name: Deploy to GitHub Pages
114+
id: deployment
115+
uses: actions/deploy-pages@v4

scripts/gen_docs.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
readonly THIS_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd | xargs realpath)"
66
readonly ROOT_DIR="${THIS_DIR}/.."
7+
readonly FAVICON_PATH="${ROOT_DIR}/.ci/html/images/favicon.ico"
78

89
function main() {
910
if [[ $# -gt 1 ]]; then
@@ -14,16 +15,18 @@ function main() {
1415
set -e
1516
trap exit SIGINT
1617

17-
local outputDir="${ROOT_DIR}/html"
18+
local output_dir="${ROOT_DIR}/html"
1819
if [[ $# -gt 0 ]]; then
19-
outputDir=$1
20+
output_dir=$1
2021
fi
2122

2223
cd "${ROOT_DIR}"
2324

24-
mkdir -p "${outputDir}"
25+
mkdir -p "${output_dir}"
26+
27+
pdoc --output-directory "${output_dir}" --favicon "$(basename "${FAVICON_PATH}")" ./pacai edq !.*_test
28+
cp "${FAVICON_PATH}" "${output_dir}"
2529

26-
pdoc --output-directory "${outputDir}" ./pacai edq !.*_test
2730
return $?
2831
}
2932

0 commit comments

Comments
 (0)