Skip to content

Commit 431c59f

Browse files
committed
Add docs generation and on-demand deploy
1 parent f3562fe commit 431c59f

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/basic.yml

Lines changed: 64 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+
deploy_documentation:
13+
description: Deploy 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,54 @@ jobs:
4659

4760
- name: Run tests
4861
run: cargo test --verbose
62+
63+
- name: Generate documentation
64+
run: |
65+
cargo doc -p oneapi-rs --no-deps --verbose
66+
cat > target/doc/index.html <<'HTML'
67+
<!doctype html>
68+
<html lang="en">
69+
<head>
70+
<meta charset="utf-8">
71+
<meta http-equiv="refresh" content="0; url=oneapi_rs/">
72+
<title>oneapi-rs documentation</title>
73+
</head>
74+
<body>
75+
<p><a href="oneapi_rs/">oneapi-rs documentation</a></p>
76+
</body>
77+
</html>
78+
HTML
79+
80+
- name: Upload documentation artifact
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: documentation
84+
path: target/doc
85+
86+
deploy-documentation:
87+
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.deploy_documentation)
88+
needs: build
89+
runs-on: ubuntu-latest
90+
91+
environment:
92+
name: github-pages
93+
url: ${{ steps.deployment.outputs.page_url }}
94+
95+
steps:
96+
- name: Download documentation artifact
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: documentation
100+
path: target/doc
101+
102+
- name: Configure GitHub Pages
103+
uses: actions/configure-pages@v5
104+
105+
- name: Upload documentation to GitHub Pages
106+
uses: actions/upload-pages-artifact@v3
107+
with:
108+
path: target/doc
109+
110+
- name: Deploy documentation to GitHub Pages
111+
id: deployment
112+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)