Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Documentation

on:
pull_request:
branches: [ main ]
paths:
- 'arbi/**'
- '.github/workflows/docs.yml'
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write
pull-requests: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-deploy-docs:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
run: |
rustup toolchain install nightly
rustup override set nightly
- name: Build static files (documentation)
run: |
RUSTDOCFLAGS="--html-in-header ./arbi/doc/header.html --cfg docsrs" cargo +nightly doc --no-deps --all-features
- name: Prepare PR-specific path
if: github.event_name == 'pull_request'
run: |
mkdir -p "pr-${{ github.event.number }}"
mv target/doc "pr-${{ github.event.number }}/doc"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Comment on PR - documentation preview link
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const url = `${{ steps.deployment.outputs.page_url }}pr-${{ github.event.number }}/doc/arbi/index.html`;
const timestamp = new Date().toISOString();
const commit_hash = context.payload.pull_request.head.sha;
const message = `📚 Documentation preview: ${url}\n\n_Last updated: ${timestamp}_\n_Commit: ${commit_hash}_`;

// Look for an existing documentation preview comment.
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
const doc_comment = comments.data.find(comment =>
comment.body.includes('📚 Documentation preview')
);

const comment_params = {
owner: context.repo.owner,
repo: context.repo.repo,
body: message
};

if (doc_comment) {
// If a comment exists, update the existing one.
await github.rest.issues.updateComment({
...comment_params,
comment_id: doc_comment.id,
});
} else {
// If no comment exists, create a new one.
await github.rest.issues.createComment({
...comment_params,
issue_number: context.payload.pull_request.number,
});
}
Loading