diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml
index c55006d8e..bec29335d 100644
--- a/.github/workflows/documentation.yml
+++ b/.github/workflows/documentation.yml
@@ -30,9 +30,6 @@ jobs:
- name: Init install
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} && rustup component add clippy
- - name: Create Docs
- run: cargo doc --no-deps
-
- - name: Run script for copying docs
+ - name: Run script for createing and copying docs in gh-pages branch
run: ./doc_preparation.sh
\ No newline at end of file
diff --git a/doc_preparation.sh b/doc_preparation.sh
index 674bececd..04e152c28 100755
--- a/doc_preparation.sh
+++ b/doc_preparation.sh
@@ -1,4 +1,36 @@
+#!/usr/bin/env bash
+set -euxo pipefail
+
+die() {
+ local msg="$*"
+ [[ -z "${msg}" ]] || {
+ echo "${RED}${msg}${RESET}" 1>&2
+ }
+ exit 1
+}
+readonly -f die
+
+directory=docs
+branch=gh-pages
+
+echo -e "Deleting old content if exists..."
+rm -rf $directory
+
+echo -e "Checking out $branch...."
+git worktree add $directory -f $branch
+
+echo -e "Rebuilding docs..."
cargo doc --no-deps
-rm -rf ./docs
+
+echo -e "Preparing the link html and copying docs..."
echo "" > target/doc/index.html
-cp -r target/doc ./docs
\ No newline at end of file
+cp -r target/doc $directory
+
+echo -e "Deploying $branch branch..."
+cd $directory &&
+ git add --all &&
+ GIT_COMMITTER_NAME='Docs builder' GIT_COMMITTER_EMAIL='info@parity.io' git commit --author "Docs builder " -m "Deploy updates" &&
+ git push origin $branch
+
+echo -e "Cleaning up..."
+git worktree remove -f $directory