From 898035bef1d38f8fb794de7ddc68e8c8f6a6ca47 Mon Sep 17 00:00:00 2001 From: "The Artifex (4r7if3x)" Date: Wed, 12 Jun 2024 03:55:47 +0200 Subject: [PATCH] Configured GitHub workflow --- .github/workflows/deploy.yml | 120 +++++++++++++++++++++++++++++++++++ redirect.html | 16 +++++ versions.json | 4 ++ 3 files changed, 140 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 redirect.html create mode 100644 versions.json diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..798b143 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,120 @@ +name: Deploy + +on: + push: + branches: + - main + path: + - 'Writerside/**' + +permissions: + id-token: write + pages: write + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - pre-alpha + - v1 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Writerside docs + run: | + commands=$(cat <&1 | tee algolia-update-index-log.txt + EOF) + docker run --rm -v $GITHUB_WORKSPACE:/home -w /home registry.jetbrains.team/p/writerside/builder/algolia-publisher:2.0.32-2 /bin/bash -c "$command" + continue-on-error: true + + - name: Upload Writerside docs + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.version }}-docs + path: artifacts/webHelp*2-all.zip + if-no-files-found: error + retention-days: 7 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + sudo apt update -y + sudo apt install -y jq + + - name: Checkout repository + uses: actions/checkout@v4 + with: + sparse-checkout: | + versions.json + redirect.html + sparse-checkout-cone-mode: false + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Prepare web directory + run: | + mkdir htdocs + cp versions.json htdocs/ + versions=($(jq -r '.[].version' versions.json)) + for index in "${!versions[@]}"; do + version="${versions[index]}" + web_path="htdocs/${index}.x" + unzip -q "artifacts/${version}-docs/webHelp${version^^}2-all.zip" -d "$web_path" + sed 's;#{path};;g' redirect.html > "${web_path}/index.html" + done + current_version="$(jq -r 'map(.isCurrent) | index(true)' versions.json).x" + sed "s;#{path};${current_version}/;g" redirect.html > htdocs/index.html + + - name: Setup GitHub Pages + uses: actions/configure-pages@v3 + + - name: Upload web directory + uses: actions/upload-pages-artifact@v2 + with: + path: htdocs + + - name: Deploy GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/redirect.html b/redirect.html new file mode 100644 index 0000000..b316776 --- /dev/null +++ b/redirect.html @@ -0,0 +1,16 @@ + + + + + You will be redirected shortly + + + + + + +

Redirecting…

+ Click here if you are not redirected! + + + diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..a7eaf0b --- /dev/null +++ b/versions.json @@ -0,0 +1,4 @@ +[ + { "version": "pre-alpha", "url": "/docs/0.x", "isCurrent": true }, + { "version": "v1", "url": "/docs/1.x", "isCurrent": false } +]