Build and Deploy Documentation #15
This file contains hidden or 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: Build and Deploy Documentation | |
| on: | |
| workflow_dispatch: # Enables manual trigger | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Install Go Task | |
| run: | | |
| curl -L https://github.com/go-task/task/releases/download/v3.14.0/task_linux_amd64.tar.gz | tar xz | |
| sudo mv task /usr/local/bin/ | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install pipenv | |
| pipenv lock --clear | |
| pipenv install --dev --deploy | |
| - name: Fetch all branches | |
| run: | | |
| git fetch --all --prune | |
| - name: Build documentation (all versions) | |
| run: | | |
| # Determine latest version from mkdocs.yml (last line in extra.versions) | |
| LATEST_VERSION="$(tail -n 1 mkdocs.yml | sed 's/://')" | |
| echo "Latest documentation version: ${LATEST_VERSION}" | |
| # Build all versions using mkdocs_versioned (similar to build.sh) | |
| pipenv run mkdocs_versioned --default-branch="${LATEST_VERSION}" | |
| # Copy issue report page into the built site root | |
| cp issue_report.php site/ | |
| - name: Create documentation archive | |
| run: | | |
| tar -czvf csdocs.tar.gz -C site . | |
| - name: Upload documentation as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: csdocs | |
| path: ./csdocs.tar.gz | |
| if-no-files-found: error | |
| - name: Publish | |
| uses: nogsantos/scp-deploy@master | |
| with: | |
| src: csdocs.tar.gz | |
| remote: /tmp/csdocs.tar.gz | |
| host: ${{ secrets.HOST_IP }} | |
| port: 22 | |
| user: jelastic | |
| key: ${{ secrets.SSH_KEY }} | |
| - name: Update | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.HOST_IP }} | |
| username: jelastic | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| script: | | |
| rm -rf /tmp/public; mkdir -p /tmp/public; tar -xzf /tmp/csdocs.tar.gz -C /tmp/public/; | |
| #rsync -az --delete /tmp/public/ /var/www/webroot/ROOT/site/; |