Publish Docs #2167
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Publish Docs" | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["CI"] | |
| branches: ["master", "release"] | |
| types: | |
| - completed | |
| jobs: | |
| publishing: | |
| name: Publish Documentation | |
| if: github.ref_name == 'master' || github.ref_name == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 📥 Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get latest stable version tag | |
| if: github.ref_name == 'release' | |
| id: get_version | |
| run: | | |
| latest_tag=$(git describe --tags --abbrev=0) | |
| echo "version=${latest_tag#v}" >> $GITHUB_OUTPUT | |
| - name: ❄ Setup Nix/Cachix | |
| uses: ./.github/actions/nix-cachix-setup | |
| with: | |
| authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}' | |
| - name: Build documentation and compute benchmarks | |
| env: | |
| DOCS_VERSION: ${{ github.ref_name == 'master' && 'unstable' || steps.get_version.outputs.version }} | |
| run: | | |
| # Release | |
| DERIVATION=docs | |
| OUT_PATH= | |
| [[ ${{ github.ref_name }} = "master" ]] && \ | |
| DERIVATION=docs-unstable && \ | |
| OUT_PATH=/unstable | |
| # This is used by the yarn build to determine the version to write up | |
| # the top, and otherwise determine if it's the unstable version or | |
| # not. | |
| # We need to use this specific scheme because | |
| echo "export DOCS_VERSION=${DOCS_VERSION}" > docs/yarn.env | |
| nix build .#${DERIVATION} | |
| export out=/tmp/public/head-protocol${OUT_PATH} | |
| mkdir -p $out | |
| cp result/build/* $out -r | |
| sudo chmod -R 777 /tmp/public | |
| nix develop .#hydra-node-bench --command -- tx-cost --output-directory $out/benchmarks/ | |
| nix develop .#hydra-node-bench --command -- micro -o $out/benchmarks/ledger-bench.html | |
| nix develop .#hydra-cluster-bench --command -- \ | |
| bench-e2e \ | |
| datasets \ | |
| hydra-cluster/datasets/1-node.json \ | |
| hydra-cluster/datasets/3-nodes.json \ | |
| --output-directory $out/benchmarks | |
| - name: 👉 Create redirects | |
| run: | | |
| function redirect() { | |
| echo "Creating redirect: $1 -> $2" | |
| mkdir -p $(dirname $1) | |
| echo "<!DOCTYPE html><html><head><meta http-equiv=\"Refresh\" content=\"0; URL=${2}\"></head></html>" > $1 | |
| } | |
| echo "hydra.family" > /tmp/public/CNAME | |
| touch /tmp/public/.nojekyll | |
| redirect /tmp/public/index.html https://hydra.family/head-protocol | |
| # Monthly reports moved to scaling website (2024-02-29) | |
| rm -rf /tmp/public/head-protocol/monthly | |
| # Note: This runs on pushes to either branch, but it doesn't matter as | |
| # it doesn't hurt to write these files twice. | |
| redirect /tmp/public/head-protocol/monthly/index.html https://cardano-scaling.github.io/website/monthly | |
| redirect /tmp/public/head-protocol/unstable/monthly/index.html https://cardano-scaling.github.io/website/monthly | |
| - name: 🚢 Publish Documentation | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
| folder: /tmp/public | |
| # Note: This is crucial! We _never_ remove files that we have | |
| # previously uploaded. This might be surprising if we expect something | |
| # we previously uploaded to be _removed_! | |
| clean: false |