Skip to content

Deploy rustdoc

Deploy rustdoc #58

name: Deploy rustdoc
on:
workflow_dispatch:
workflow_run:
workflows: ["Check codebase"]
branches:
- develop
- master
- 'refs/tags/[0-9]+.[0-9]+.[0-9]+*'
types:
- completed
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-rustdoc:
name: Build rustdoc
runs-on: ubuntu-latest
env:
DOCS_TARGET: target/doc
BRANCH: gh-pages
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run `cargo doc`
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/workspace" \
-v "${HOME}/.cargo:/root/.cargo" \
-e RUSTDOCFLAGS='-D warnings' \
-w /workspace \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
cargo doc --all-features --no-deps --locked && \
mv $DOCS_TARGET/help.html $DOCS_TARGET/index.html && \
chown -R $(id -u):$(id -g) $DOCS_TARGET"
- name: Set target folder for non-master branches
if: github.ref_name != 'master'
run: echo "TARGET_FOLDER=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Push to gh-pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: ${{ env.BRANCH }}
folder: ${{ env.DOCS_TARGET }}
target-folder: ${{ env.TARGET_FOLDER }}
deploy-rustdoc:
name: Deploy rustdoc
environment:
name: gh-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-rustdoc
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4