Skip to content

Commit 9612a1f

Browse files
committed
Add on-demand docs generation and deploy
1 parent 548dade commit 9612a1f

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/basic.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@ on:
77
pull_request:
88
branches: [ "main" ]
99

10+
workflow_dispatch:
11+
inputs:
12+
generate_documentation:
13+
description: Generate documentation
14+
required: false
15+
type: boolean
16+
default: false
17+
1018
env:
1119
CARGO_TERM_COLOR: always
1220

21+
permissions:
22+
contents: read
23+
pages: write
24+
id-token: write
25+
1326
jobs:
1427
build:
1528
runs-on: ubuntu-latest
@@ -46,3 +59,31 @@ jobs:
4659

4760
- name: Run tests
4861
run: cargo test --verbose
62+
63+
- name: Generate documentation (on demand)
64+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
65+
run: cargo doc --workspace --no-deps --verbose
66+
67+
- name: Configure GitHub Pages
68+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
69+
uses: actions/configure-pages@v5
70+
71+
- name: Upload documentation to GitHub Pages
72+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
73+
uses: actions/upload-pages-artifact@v3
74+
with:
75+
path: target/doc
76+
77+
deploy-documentation:
78+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
79+
needs: build
80+
runs-on: ubuntu-latest
81+
82+
environment:
83+
name: github-pages
84+
url: ${{ steps.deployment.outputs.page_url }}
85+
86+
steps:
87+
- name: Deploy documentation to GitHub Pages
88+
id: deployment
89+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)