diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000000..3fe541ba5d --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,44 @@ +name: Deploy PR Preview +# Only run when a PR have the 'preview' label +on: + pull_request: + types: + - labeled + +concurrency: preview-${{ github.ref }} + +jobs: + build-and-deploy-preview: + if: github.event.label.name == 'preview' + runs-on: ubuntu-latest + container: sphinxdoc/sphinx + steps: + - name: Install git 🔧 + shell: bash + run: | + apt-get update + apt-get install -y git + + - name: Checkout 🛎️ + uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 + + - name: Install 🔧 + shell: bash + run: | + apt-get install -y graphviz rsync + pip3 install -r requirements.txt + + - name: Build 🛠 + shell: bash + run: ./scripts/build.sh + + - name: Deploy preview 🚀 + uses: rossjrw/pr-preview-action@v1 + with: + preview-branch: gh-pages + umbrella-dir: pr-preview + custom-url: developer.concordium.software + source-dir: ./build + action: deploy diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c1ab3afc74..4c0a84c6b8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,4 +33,7 @@ jobs: with: branch: gh-pages folder: build + # Prevent the default behavior of force pushing which will remove previews see https://github.com/marketplace/actions/deploy-pr-preview. + force: false clean: true + clean-exclude: pr-preview/ diff --git a/.github/workflows/remove-preview.yml b/.github/workflows/remove-preview.yml new file mode 100644 index 0000000000..7ba48550e5 --- /dev/null +++ b/.github/workflows/remove-preview.yml @@ -0,0 +1,19 @@ +name: Remove PR Preview + +on: + pull_request: + types: + - closed # This hook is needed to remove the preview when PR is closed. + +jobs: + remove-preview: + runs-on: ubuntu-latest + steps: + - name: Remove preview + uses: rossjrw/pr-preview-action@v1 + with: + preview-branch: gh-pages + umbrella-dir: pr-preview + source-dir: ./build + action: remove + diff --git a/CLAs/Contributor-License-Agreement-v1.0.pdf b/public/CLAs/Contributor-License-Agreement-v1.0.pdf similarity index 100% rename from CLAs/Contributor-License-Agreement-v1.0.pdf rename to public/CLAs/Contributor-License-Agreement-v1.0.pdf diff --git a/extra/Terms-and-conditions-Mobile-Wallet.pdf b/public/extra/Terms-and-conditions-Mobile-Wallet.pdf similarity index 100% rename from extra/Terms-and-conditions-Mobile-Wallet.pdf rename to public/extra/Terms-and-conditions-Mobile-Wallet.pdf diff --git a/extra/background-img.png b/public/extra/background-img.png similarity index 100% rename from extra/background-img.png rename to public/extra/background-img.png diff --git a/extra/concordium-logo-dark.svg b/public/extra/concordium-logo-dark.svg similarity index 100% rename from extra/concordium-logo-dark.svg rename to public/extra/concordium-logo-dark.svg diff --git a/extra/testnet.html b/public/extra/testnet.html similarity index 100% rename from extra/testnet.html rename to public/extra/testnet.html diff --git a/extra/testnet4.html b/public/extra/testnet4.html similarity index 100% rename from extra/testnet4.html rename to public/extra/testnet4.html diff --git a/index.html b/public/index.html similarity index 100% rename from index.html rename to public/index.html diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000000..9b71923988 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +# Tell crawlers to ignore PR preview builds. +User-agent: * +Disallow: /pr-preview/ diff --git a/scripts/build.sh b/scripts/build.sh index 27d85b6e1c..bdb2c3c5f0 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -27,14 +27,8 @@ printf "Building documentation versions: ${all_versions} for languages ${all_lan mkdir -p "${build_dir}" -printf "Copying index.html to ${build_dir}\n" -cp index.html "${build_dir}/index.html" - -printf "Copying CLAs to ${build_dir}\n" -cp -r CLAs "${build_dir}/CLAs" - -printf "Copying 'extra' directory to ${build_dir}\n" -cp -r extra "${build_dir}/extra" +printf "Copying 'public' to '${build_dir}'\n" +cp -rv public/* ${build_dir} for current_version in ${versions[@]}; do printf "\nVersion '${current_version}':\n-----------------------------\n"