Skip to content

Commit

Permalink
feat: rust-doc to github pages (privacy-scaling-explorations#1578)
Browse files Browse the repository at this point in the history
### Description

This pull request aims to run the cargo doc in CI to generate and
publish the doc to GitHub Pages.

### Issue Link

Solving privacy-scaling-explorations#1206 

### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Contents

The implementation is in _.github/workflows/github-pages.yml_.
The goal is to generate the doc, upload the doc, and deploy the page.

### How Has This Been Tested?

I have tested this in my [forked
repository](https://github.com/ryanycw/zkevm-circuits/actions/workflows/github-pages.yml).
And here is the
[demo](https://ryanycw.github.io/zkevm-circuits/zkevm_circuits/) of what
the result will look like.

---------

Co-authored-by: Chih Cheng Liang <[email protected]>
  • Loading branch information
ryanycw and ChihChengLiang authored Sep 4, 2023
1 parent 818ecbc commit 8de9cd3
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- name: Setup Pages
uses: actions/configure-pages@v3
# Create a index.html outside of the subdirectories for requirement of GitHub pages
- name: Generate Docs
run: |
cargo doc --no-deps
echo "<meta http-equiv=\"refresh\" content=\"0; url=zkevm_circuits\">" > target/doc/index.html
# Archive the artifact with the correct permissions
# https://github.com/actions/deploy-pages/issues/188
- name: Archive artifact
shell: sh
run: |
chmod -c -R +rX "target/doc" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "target/doc" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'target/doc'

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

0 comments on commit 8de9cd3

Please sign in to comment.