From 0dace6b30e52b9b560132e44c764b3dfaf34d840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Holm=20Gj=C3=B8rup?= Date: Thu, 10 Aug 2023 13:51:32 +0200 Subject: [PATCH 1/2] Add deploy preview action --- .github/workflows/deploy-preview.yml | 44 ++++++++++++++++++ .github/workflows/deploy.yml | 3 ++ .github/workflows/remove-preview.yml | 24 ++++++++++ .../Contributor-License-Agreement-v1.0.pdf | Bin .../Terms-and-conditions-Mobile-Wallet.pdf | Bin {extra => public/extra}/background-img.png | Bin .../extra}/concordium-logo-dark.svg | 0 {extra => public/extra}/testnet.html | 0 {extra => public/extra}/testnet4.html | 0 index.html => public/index.html | 0 public/robots.txt | 3 ++ scripts/build.sh | 10 +--- 12 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/deploy-preview.yml create mode 100644 .github/workflows/remove-preview.yml rename {CLAs => public/CLAs}/Contributor-License-Agreement-v1.0.pdf (100%) rename {extra => public/extra}/Terms-and-conditions-Mobile-Wallet.pdf (100%) rename {extra => public/extra}/background-img.png (100%) rename {extra => public/extra}/concordium-logo-dark.svg (100%) rename {extra => public/extra}/testnet.html (100%) rename {extra => public/extra}/testnet4.html (100%) rename index.html => public/index.html (100%) create mode 100644 public/robots.txt 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..208389c48c --- /dev/null +++ b/.github/workflows/remove-preview.yml @@ -0,0 +1,24 @@ +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: Checkout πŸ›ŽοΈ + uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 + + - 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" From 7dc3dfa758db2059d521d7ba916fd6f62118ad37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Holm=20Gj=C3=B8rup?= Date: Thu, 10 Aug 2023 16:49:04 +0200 Subject: [PATCH 2/2] Update .github/workflows/deploy-preview.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: AleΕ‘ Bizjak --- .github/workflows/deploy-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 3fe541ba5d..0988286beb 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -1,5 +1,5 @@ name: Deploy PR Preview -# Only run when a PR have the 'preview' label +# Only run when a PR has the 'preview' label on: pull_request: types: