diff --git a/.github/workflows/dev-documentation.yml b/.github/workflows/dev-documentation.yml index 32ffb11..854e27e 100644 --- a/.github/workflows/dev-documentation.yml +++ b/.github/workflows/dev-documentation.yml @@ -6,6 +6,9 @@ on: - master workflow_dispatch: +env: + CI_DOCKER_CACHE_PATH: ci/cache/docker + # Мы хотим чтобы deploy в ветку gh-pages # происходили консистентно друг за другом concurrency: @@ -19,6 +22,10 @@ jobs: deploy: name: Deploy dev documentation runs-on: ubuntu-22.04 + env: + RENDERER_NETWORK: renderer-net + RENDERER_IMAGE: plantuml/plantuml-server:jetty-v1.2026.0 + RENDERER_CONTAINER_NAME: renderer defaults: run: working-directory: documentation @@ -26,18 +33,58 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 + + - name: Setup docker image cache + id: docker-image-cache + uses: actions/cache@v3 + with: + path: ${{ env.CI_DOCKER_CACHE_PATH }} + key: ${{ env.RENDERER_IMAGE }} + + - name: Update docker image cache + if: steps.docker-image-cache.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }} + run: | + docker pull "$RENDERER_IMAGE" + mkdir -p ${CI_DOCKER_CACHE_PATH}/${RENDERER_IMAGE} + docker image save -o ${CI_DOCKER_CACHE_PATH}/${RENDERER_CONTAINER_NAME}.tar "$RENDERER_IMAGE" + + - name: Load docker image cache + if: steps.docker-image-cache.outputs.cache-hit == 'true' + working-directory: ${{ github.workspace }} + run: | + docker image load -i ${CI_DOCKER_CACHE_PATH}/${RENDERER_CONTAINER_NAME}.tar + + - name: Start renderer service locally + run: | + docker network create "$RENDERER_NETWORK" + docker run -d -p 7036:8080 --name "$RENDERER_CONTAINER_NAME" --network "$RENDERER_NETWORK" "$RENDERER_IMAGE" + + - name: Configure Git user run: | git config user.email "actions@github.com" git config user.name "GitHub Actions" + + - name: Setup python uses: actions/setup-python@v5 with: python-version: 3.x cache: 'pip' + - name: Download mkdocs plugins run: pip install -r requirements.txt + - name: Deploy documentation into gh-pages branch run: mike deploy dev --push + - name: Setup default version run: mike set-default dev --push + + - name: Cleanup renderer container + if: always() + run: | + docker rm -f "$RENDERER_CONTAINER_NAME" + docker network rm -f "$RENDERER_NETWORK" + docker rmi -f ${RENDERER_REGISTRY}${RENDERER_IMAGE} diff --git a/.github/workflows/release-documentation.yml b/.github/workflows/release-documentation.yml index 03978b7..397feb2 100644 --- a/.github/workflows/release-documentation.yml +++ b/.github/workflows/release-documentation.yml @@ -8,6 +8,9 @@ on: required: true type: string +env: + CI_DOCKER_CACHE_PATH: ci/cache/docker + # Мы хотим чтобы deploy в ветку gh-pages # происходили консистентно друг за другом concurrency: @@ -21,6 +24,10 @@ jobs: deploy: name: Deploy release documentation runs-on: ubuntu-22.04 + env: + RENDERER_NETWORK: renderer-net + RENDERER_IMAGE: plantuml/plantuml-server:jetty-v1.2026.0 + RENDERER_CONTAINER_NAME: renderer steps: - name: Validate semver tag format id: validate-tag @@ -38,12 +45,39 @@ jobs: echo "✅ Valid tag: $TAG" echo "Version for docs: $VERSION" echo "version=$VERSION" >> $GITHUB_OUTPUT + - name: Checkout repository with tag uses: actions/checkout@v6 with: ref: "${{ github.event.inputs.tag }}" fetch-depth: 0 + - name: Setup docker image cache + id: docker-image-cache + uses: actions/cache@v3 + with: + path: ${{ env.CI_DOCKER_CACHE_PATH }} + key: ${{ env.RENDERER_IMAGE }} + + - name: Update docker image cache + if: steps.docker-image-cache.outputs.cache-hit != 'true' + working-directory: ${{ github.workspace }} + run: | + docker pull "$RENDERER_IMAGE" + mkdir -p ${CI_DOCKER_CACHE_PATH}/${RENDERER_IMAGE} + docker image save -o ${CI_DOCKER_CACHE_PATH}/${RENDERER_CONTAINER_NAME}.tar "$RENDERER_IMAGE" + + - name: Load docker image cache + if: steps.docker-image-cache.outputs.cache-hit == 'true' + working-directory: ${{ github.workspace }} + run: | + docker image load -i ${CI_DOCKER_CACHE_PATH}/${RENDERER_CONTAINER_NAME}.tar + + - name: Start renderer service locally + run: | + docker network create "$RENDERER_NETWORK" + docker run -d -p 7036:8080 --name "$RENDERER_CONTAINER_NAME" --network "$RENDERER_NETWORK" ${RENDERER_REGISTRY}${RENDERER_IMAGE} + - name: Configure Git user run: | git config user.email "actions@github.com" @@ -66,3 +100,10 @@ jobs: # env: # # Для дебага, если нужно # MIKE_VERBOSE: 1 + + - name: Cleanup renderer container + if: always() + run: | + docker rm -f "$RENDERER_CONTAINER_NAME" + docker network rm -f "$RENDERER_NETWORK" + docker rmi -f ${RENDERER_REGISTRY}${RENDERER_IMAGE} diff --git a/documentation/README.md b/documentation/README.md index 588db08..afc7e00 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -13,8 +13,11 @@ source venv/bin/activate pip install -r requirements.txt ``` - -2. Соберите или запустите сайт: +2. Необходим `docker`. Запустите сервер рендеринга локально: + ```shell + docker run -d -p 7036:8080 plantuml/plantuml-server:jetty-v1.2026.0 + ``` +3. Соберите или запустите сайт: ```shell mkdocs build diff --git a/documentation/README_EN.md b/documentation/README_EN.md index e0d0be2..9b4f828 100644 --- a/documentation/README_EN.md +++ b/documentation/README_EN.md @@ -13,8 +13,11 @@ To deploy documentation locally on current branch/tag: source venv/bin/activate pip install -r requirements.txt ``` - -2. Build or serve site: +2. Requires `docker`. Start the render server locally: + ```shell + docker run -d -p 7036:8080 plantuml/plantuml-server:jetty-v1.2026.0 + ``` +3. Build or serve site: ```shell mkdocs build diff --git a/documentation/mkdocs.yml b/documentation/mkdocs.yml index 7516750..7d73616 100644 --- a/documentation/mkdocs.yml +++ b/documentation/mkdocs.yml @@ -47,7 +47,7 @@ plugins: - drawio: darkmode: true - plantuml: - puml_url: https://www.plantuml.com/plantuml/ + puml_url: http://localhost:7036 # в секундах(in seconds) request_timeout: 300