|
| 1 | +name: Build and Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + # Build preview documentation for pull requests |
| 5 | + pull_request: |
| 6 | + # Build and deploy documentation for master branch |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-docs: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v5 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: '3.12' |
| 21 | + |
| 22 | + - name: Install system dependencies |
| 23 | + run: | |
| 24 | + sudo apt-get update |
| 25 | + sudo apt-get install -y doxygen graphviz |
| 26 | +
|
| 27 | + - name: Install Python dependencies |
| 28 | + working-directory: docs |
| 29 | + run: | |
| 30 | + pip install -r requirements.txt |
| 31 | +
|
| 32 | + - name: Build documentation |
| 33 | + working-directory: docs |
| 34 | + run: | |
| 35 | + chmod +x build_docs.sh |
| 36 | + ./build_docs.sh |
| 37 | +
|
| 38 | + - name: Upload documentation artifacts |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + name: docs |
| 42 | + path: | |
| 43 | + docs/_build |
| 44 | + !docs/_build/.doctrees |
| 45 | +
|
| 46 | + deploy-docs: |
| 47 | + needs: build-docs |
| 48 | + runs-on: ubuntu-latest |
| 49 | + # Set Deploy environment for master branch, otherwise set Preview environment |
| 50 | + environment: ${{ github.ref_name == 'master' && 'esp-docs deploy' || 'esp-docs preview' }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v5 |
| 53 | + |
| 54 | + - uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: docs |
| 57 | + |
| 58 | + - name: Set up Python |
| 59 | + uses: actions/setup-python@v5 |
| 60 | + with: |
| 61 | + python-version: '3.12' |
| 62 | + |
| 63 | + - name: Install Python dependencies |
| 64 | + working-directory: docs |
| 65 | + run: | |
| 66 | + pip install -r requirements.txt |
| 67 | +
|
| 68 | + - name: Get git version |
| 69 | + id: git_version |
| 70 | + run: | |
| 71 | + git_ver=$(git describe --always) |
| 72 | + echo "version=$git_ver" >> $GITHUB_OUTPUT |
| 73 | + echo "GIT_VER=$git_ver" >> $GITHUB_ENV |
| 74 | +
|
| 75 | + - name: Set up SSH |
| 76 | + run: | |
| 77 | + mkdir -p ~/.ssh |
| 78 | + echo "${{ secrets.DOCS_PRIVATEKEY }}" > ~/.ssh/id_rsa |
| 79 | + chmod 600 ~/.ssh/id_rsa |
| 80 | + ssh-keyscan -H ${{ vars.DOCS_SERVER }} >> ~/.ssh/known_hosts || true |
| 81 | +
|
| 82 | + - name: Deploy documentation |
| 83 | + working-directory: docs |
| 84 | + env: |
| 85 | + GIT_VER: ${{ steps.git_version.outputs.version }} |
| 86 | + DOCS_BUILD_DIR: ${{ github.workspace }}/docs/_build |
| 87 | + DOCS_DEPLOY_URL_BASE: ${{ vars.DOCS_URL_BASE }} |
| 88 | + DOCS_DEPLOY_SERVER: ${{ vars.DOCS_SERVER }} |
| 89 | + DOCS_DEPLOY_SERVER_USER: ${{ secrets.DOCS_SERVER_USER }} |
| 90 | + DOCS_DEPLOY_PATH: ${{ vars.DOCS_PATH }} |
| 91 | + # TYPE is optional - only used for output formatting (shows "deploy" or "preview" in logs) |
| 92 | + #TYPE: ${{ github.ref_name == 'master' && 'deploy' || 'preview' }} |
| 93 | + run: | |
| 94 | + deploy-docs |
0 commit comments