Skip to content

Commit c6925ed

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

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

.github/workflows/basic.yml

Lines changed: 58 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,48 @@ 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: Add documentation landing page
68+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
69+
run: |
70+
cat > target/doc/index.html <<'HTML'
71+
<!doctype html>
72+
<html lang="en">
73+
<head>
74+
<meta charset="utf-8">
75+
<meta http-equiv="refresh" content="0; url=oneapi_rs/">
76+
<title>oneapi-rs documentation</title>
77+
</head>
78+
<body>
79+
<p><a href="oneapi_rs/">oneapi-rs documentation</a></p>
80+
</body>
81+
</html>
82+
HTML
83+
84+
- name: Configure GitHub Pages
85+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
86+
uses: actions/configure-pages@v5
87+
88+
- name: Upload documentation to GitHub Pages
89+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
90+
uses: actions/upload-pages-artifact@v3
91+
with:
92+
path: target/doc
93+
94+
deploy-documentation:
95+
if: github.event_name == 'workflow_dispatch' && inputs.generate_documentation
96+
needs: build
97+
runs-on: ubuntu-latest
98+
99+
environment:
100+
name: github-pages
101+
url: ${{ steps.deployment.outputs.page_url }}
102+
103+
steps:
104+
- name: Deploy documentation to GitHub Pages
105+
id: deployment
106+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)