|
1 | 1 | name: Deploy Doc
|
2 | 2 |
|
3 | 3 | on: workflow_call
|
4 |
| -jobs: |
5 |
| - deploy-docs: |
| 4 | +jobs: |
| 5 | + deploy-doc: |
6 | 6 | runs-on: ubuntu-latest
|
7 |
| - # needs: docs |
8 |
| - # if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/sphinx-web-documentation') |
| 7 | + permissions: |
| 8 | + contents: write |
| 9 | + |
9 | 10 | steps:
|
10 |
| - - name: Update gh pages |
11 |
| - run: | |
12 |
| - git config --global user.email "[email protected]" |
13 |
| - git config --global user.name "CSE-CI" |
14 |
| -
|
15 |
| - MASTER_COMMIT=$(git rev-parse --short HEAD) |
16 |
| - REPO_SLUG="${REPO_SLUG:-analogdevicesinc/precision-converters-firmware}" |
17 |
| -
|
18 |
| - # Fetch and checkout to gh-pages branch |
19 |
| - git fetch --depth 1 origin +refs/heads/gh-pages:gh-pages |
20 |
| - git checkout gh-pages |
21 |
| -
|
22 |
| - # Clear previous content in the root folder of 'gh-pages' branch except |
23 |
| - # the 'doc' folder which holds new builds |
24 |
| - find -mindepth 1 -maxdepth 1 ! \( -name "doc" -o -name ".git" \) -exec rm -rf {} \; |
25 |
| - |
26 |
| - # Add sphinx build html content to root folder in the 'gh-pages' branch |
27 |
| - cp -r doc/sphinx/build/* ./ |
28 |
| -
|
29 |
| - # Create doxygen folder holding new build content and add doxygen html content |
30 |
| - # to doxygen/ folder in the 'gh-pages' branch |
31 |
| - mkdir -p doxygen |
32 |
| - cp -r doc/doxygen/build/html/* doxygen/ |
33 |
| -
|
34 |
| - # Remove temporary 'doc' folder |
35 |
| - rm -rf doc/ |
36 |
| -
|
37 |
| - # Create .nojekyll file to handle files starting with '_' on gh pages |
38 |
| - touch .nojekyll |
39 |
| -
|
40 |
| - # Push contents to 'gh-pages' branch |
41 |
| - CURRENT_COMMIT=$(git log -1 --pretty=%B) |
42 |
| - if [[ ${CURRENT_COMMIT:(-7)} != ${MASTER_COMMIT:0:7} ]] |
43 |
| - then |
44 |
| - git add --all . |
45 |
| - git commit --allow-empty --amend -m "Update documentation to ${MASTER_COMMIT:0:7}" |
46 |
| - if [ -n "$GITHUB_DOC_TOKEN" ] ; then |
47 |
| - git push https://${GITHUB_DOC_TOKEN}@github.com/${REPO_SLUG} gh-pages -f |
48 |
| - else |
49 |
| - git push origin gh-pages -f |
50 |
| - fi |
51 |
| -
|
52 |
| - echo "Documetation updated!" |
53 |
| - else |
54 |
| - echo "Documentation already up to date!" |
55 |
| - fi |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + ref: 'gh-pages' |
| 13 | + |
| 14 | + - name: Empty gh-pages |
| 15 | + run: | |
| 16 | + git rm -r . --quiet |
| 17 | +
|
| 18 | + - uses: actions/download-artifact@v4 |
| 19 | + with: |
| 20 | + name: html-sphinx |
| 21 | + |
| 22 | + - uses: actions/download-artifact@v4 |
| 23 | + with: |
| 24 | + name: html-doxygen |
| 25 | + path: doxygen |
| 26 | + |
| 27 | + - name: Patch doc build |
| 28 | + run: | |
| 29 | + rm -r _sources |
| 30 | + touch .nojekyll |
| 31 | +
|
| 32 | + - name: Commit gh-pages |
| 33 | + run: | |
| 34 | + author=$(git log -1 --pretty=format:'%an') |
| 35 | + email=$(git log -1 --pretty=format:'%ae') |
| 36 | + commit=$(git rev-parse --short HEAD) |
| 37 | +
|
| 38 | + git add . >> /dev/null |
| 39 | + git config --global user.name "$author" |
| 40 | + git config --global user.email "$email" |
| 41 | + git commit -m "deploy: $commit" --allow-empty |
| 42 | +
|
| 43 | +
|
| 44 | + - name: Push to gh-pages |
| 45 | + run: >- |
| 46 | + git push origin gh-pages:gh-pages |
0 commit comments