diff --git a/.github/composite-actions/ssh-docker-compose/action.yml b/.github/composite-actions/ssh-docker-compose/action.yml index f50575521..cb7799a0d 100644 --- a/.github/composite-actions/ssh-docker-compose/action.yml +++ b/.github/composite-actions/ssh-docker-compose/action.yml @@ -19,6 +19,9 @@ inputs: docker-compose-file-frontend-build: description: 'Docker compose for frontend build file location' required: true + docker-compose-file-documentation-build: + description: 'Docker compose for documentation build file location' + required: true ci_commit: description: 'Commit ID' required: true @@ -34,6 +37,10 @@ runs: run: .github/composite-actions/ssh-docker-compose/git-pull.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} shell: bash + - name: Rebuild Documentation + run: .github/composite-actions/ssh-docker-compose/documentation-build.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} ${{ inputs.docker-compose-file-documentation-build }} ${{ inputs.ci_commit }} + shell: bash + - name: Rebuild Frontend run: .github/composite-actions/ssh-docker-compose/frontend-build.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} ${{ inputs.docker-compose-file-frontend-build }} ${{ inputs.ci_commit }} shell: bash diff --git a/.github/composite-actions/ssh-docker-compose/documentation-build.sh b/.github/composite-actions/ssh-docker-compose/documentation-build.sh new file mode 100755 index 000000000..2755da0c7 --- /dev/null +++ b/.github/composite-actions/ssh-docker-compose/documentation-build.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -eu + +# ${1} for Server IP +# ${2} for Server Port +# ${3} for Server User +# ${4} for Dockerfile location + +server_ip="${1}" +server_port="${2}" +server_user="${3}" +docker_compose_file="${4}" +ci_commit="${5}" + +ssh -i priv.key -o BatchMode=yes \ + -p "${server_port}" \ + -o UserKnownHostsFile=/dev/null \ + -o StrictHostKeyChecking=no \ + "${server_user}"@"${server_ip}" "cd src/deploy && CI_COMMIT=${ci_commit} docker compose -f ${docker_compose_file} up --build" \ No newline at end of file diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 412de8650..73f359223 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -30,6 +30,7 @@ jobs: server-ssh-user: ${{ secrets.SERVER_SSH_USER }} docker-compose-file: ${{ secrets.DOCKER_COMPOSE_FILE }} docker-compose-file-frontend-build: ${{ secrets.DOCKER_COMPOSE_FILE_FRONTEND_BUILD }} + docker-compose-file-documentation-build: ${{ secrets.DOCKER_COMPOSE_FILE_DOCUMENTATION_BUILD }} ci_commit: ${{ env.COMMIT_SHORT_SHA }} mobile-app-release: diff --git a/deploy/docker-compose.documentation-build.yml b/deploy/docker-compose.documentation-build.yml new file mode 100644 index 000000000..1af4b7689 --- /dev/null +++ b/deploy/docker-compose.documentation-build.yml @@ -0,0 +1,18 @@ +--- +services: + documentation_build: + image: akvo/akvo-sphinx:20220525.082728.594558b + container_name: documentation_build + working_dir: /docs + environment: + - CI_COMMIT=${CI_COMMIT} + command: + - /bin/bash + - -c + - | + ls -la + make html + cp -r build/html ../frontend/public/documentation + volumes: + - ../docs:/docs:delegated + - ../frontend:/frontend:delegated \ No newline at end of file diff --git a/deploy/generate_dynamic_config.sh b/deploy/generate_dynamic_config.sh index d54a4253b..d6492b41e 100755 --- a/deploy/generate_dynamic_config.sh +++ b/deploy/generate_dynamic_config.sh @@ -20,6 +20,8 @@ http: service: frontend-service tls: certResolver: myresolver + middlewares: + - redirect-documentation middlewares: redirect-to-https: @@ -27,6 +29,11 @@ http: scheme: "https" permanent: true + redirect-documentation: + redirectRegex: + regex: "^https://${WEBDOMAIN}/documentation$" + replacement: "https://${WEBDOMAIN}/documentation/" + permanent: true services: frontend-service: