Publish Docs #806
This file contains 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_run: | |
workflows: ["CI"] | |
branches: [master] | |
types: | |
- completed | |
jobs: | |
publishing: | |
name: Publish Documentation | |
runs-on: ubuntu-latest | |
# if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
repository: input-output-hk/hydra | |
ref: release | |
# Also ensure we have all history with all tags | |
fetch-depth: 0 | |
- name: Get released workflow run id | |
id: released-workflow | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let res = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'ci-nix.yaml', | |
branch: 'release', | |
status: 'success' | |
}); | |
return res.data.workflow_runs[0].id; | |
- name: Get latest workflow run id | |
id: latest-workflow | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let res = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'ci-nix.yaml', | |
branch: 'master', | |
status: 'success' | |
}); | |
return res.data.workflow_runs[0].id; | |
- name: π₯ Download released hydra-spec | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.released-workflow.outputs.result}} | |
name: hydra-spec | |
path: docs/static | |
- name: π₯ Download released benchmarks | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.released-workflow.outputs.result}} | |
pattern: benchmarks-* | |
merge-multiple: true | |
path: docs/benchmarks | |
- name: π₯ Download released test-results | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.released-workflow.outputs.result}} | |
pattern: test-results-* | |
merge-multiple: true | |
path: docs/benchmarks/tests | |
- name: π₯ Download released haddock documentation | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.released-workflow.outputs.result}} | |
name: haddocks | |
path: docs/static/haddock | |
- name: Build documentation | |
working-directory: docs | |
run: | | |
# Only warn on broken links here as the individual documentation builds | |
# should have failed with broken links originally. | |
sed -i 's|onBrokenLinks: "throw"|onBrokenLinks: "warn"|' docusaurus.config.js | |
yarn | |
yarn build | |
mkdir -p /tmp/public | |
mv build /tmp/public/head-protocol | |
# Clean the working copy | |
git clean -dxf | |
- name: Checkout master | |
working-directory: docs | |
run: | | |
git reset origin/master --hard | |
sed -i 's|head-protocol|head-protocol/unstable|' docusaurus.config.js | |
- name: π₯ Download latest hydra-spec | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.latest-workflow.outputs.result}} | |
name: hydra-spec | |
path: docs/static | |
- name: π₯ Download latest benchmarks | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.latest-workflow.outputs.result}} | |
pattern: benchmarks-* | |
merge-multiple: true | |
path: docs/benchmarks | |
- name: π₯ Download latest test-results | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.latest-workflow.outputs.result}} | |
pattern: test-results-* | |
merge-multiple: true | |
path: docs/benchmarks/tests | |
- name: π₯ Download latest haddock documentation | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
run-id: ${{steps.latest-workflow.outputs.result}} | |
name: haddocks | |
path: docs/static/haddock | |
- name: Build /unstable documentation | |
working-directory: docs | |
run: | | |
yarn | |
yarn build | |
mv build /tmp/public/head-protocol/unstable | |
- 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 | |
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 | |
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: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN || github.token }} | |
publish_dir: /tmp/public | |
enable_jekyll: true | |
force_orphan: true |