Skip to content

Commit fa56417

Browse files
committed
Deploy website from GitHub actions
0 parents  commit fa56417

10 files changed

+331
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.yaml]
12+
indent_size = 2

.github/workflows/build-website.yaml

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build website
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-docs:
9+
name: Build docs (${{ matrix.kind }})
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
kind: [internal, public]
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
repository: time-rs/time
20+
21+
- name: Cache cargo output
22+
uses: Swatinem/rust-cache@v2
23+
24+
- name: Install toolchain
25+
uses: dtolnay/rust-toolchain@nightly
26+
27+
- name: Generate documentation
28+
run: cargo doc -p time --all-features ${{ matrix.kind == 'internal' && '--document-private-items' || '' }}
29+
env:
30+
RUSTDOCFLAGS: --cfg __time_03_docs ${{ matrix.kind == 'internal' && '--document-hidden-items' || '' }} -Zunstable-options --generate-link-to-definition
31+
32+
- name: Upload artifact
33+
uses: actions/upload-artifact@v4
34+
id: docs-upload
35+
with:
36+
name: ${{ matrix.kind }}-docs
37+
path: target/doc/
38+
retention-days: 1
39+
if-no-files-found: error
40+
compression-level: 9
41+
42+
build-book:
43+
name: Build book
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
repository: time-rs/book
51+
52+
- name: Check for typos
53+
uses: crate-ci/typos@master
54+
55+
- name: Install mdbook
56+
uses: taiki-e/install-action@mdbook
57+
58+
- name: Build diagrams
59+
run: |
60+
pip install -r diagrams/requirements.txt
61+
mkdir src/diagrams
62+
python diagrams/diagrams.py
63+
64+
- name: Build book
65+
run: mdbook build
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
id: book-upload
70+
with:
71+
name: book
72+
path: book/
73+
retention-days: 1
74+
if-no-files-found: error
75+
compression-level: 9
76+
77+
deploy:
78+
name: Deploy
79+
runs-on: ubuntu-latest
80+
needs: [build-docs, build-book]
81+
permissions:
82+
pages: write
83+
id-token: write
84+
environment:
85+
name: github-pages
86+
url: ${{ steps.deployment.outputs.page_url }}
87+
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
with:
92+
sparse-checkout: |
93+
website
94+
95+
- name: Download internal docs
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: internal-docs
99+
path: website/internal-api
100+
101+
- name: Download public docs
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: public-docs
105+
path: website/api
106+
107+
- name: Download book
108+
uses: actions/download-artifact@v4
109+
with:
110+
name: book
111+
path: website/book
112+
113+
- name: Upload website
114+
uses: actions/upload-pages-artifact@v3
115+
with:
116+
path: website
117+
118+
- name: Deploy
119+
id: deployment
120+
uses: actions/deploy-pages@v4
121+
122+
- name: Delete artifacts
123+
uses: geekyeggo/delete-artifact@v4
124+
with:
125+
name: |
126+
internal-docs
127+
public-docs
128+
book
129+
github-pages
130+
failOnError: false
131+
if: always()
132+
continue-on-error: true

.github/workflows/trigger-deploy.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy
2+
3+
env:
4+
REPO: time-rs/time-rs.github.io
5+
WORKFLOW: build-website.yaml
6+
GH_TOKEN: ${{ secrets.WEBSITE_PUBLISHING }}
7+
8+
on:
9+
workflow_call:
10+
workflow_dispatch:
11+
12+
jobs:
13+
deploy:
14+
name: Deploy
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: write
18+
19+
steps:
20+
- name: Trigger deploy
21+
id: trigger
22+
run: |
23+
gh workflow run --repo ${{ env.REPO }} ${{ env.WORKFLOW }}
24+
sleep 3 # Let the run be created
25+
echo "RUN_ID=$(gh run list --repo ${{ env.REPO }} --json databaseId --workflow ${{ env.WORKFLOW }} --limit 1 | jq -r '.[0].databaseId')" >> "$GITHUB_OUTPUT"
26+
27+
- name: Wait for deployment
28+
run: gh run watch --repo ${{ env.REPO }} ${{ steps.trigger.outputs.RUN_ID }} --interval 1 --exit-status

website/icons/book.svg

+1
Loading

website/icons/code.svg

+1
Loading

website/icons/cogs.svg

+1
Loading

website/icons/github.svg

+1
Loading

website/icons/logo.svg

+1
Loading

website/index.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang='en'>
3+
4+
<head>
5+
<meta charset='UTF-8'>
6+
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
7+
<title>time-rs</title>
8+
<link rel='stylesheet' href='styles.css'>
9+
</head>
10+
11+
<body>
12+
13+
<header>
14+
<div class='branding'>
15+
<img src='icons/logo.svg'>
16+
time-rs
17+
</div>
18+
19+
<div class='right-box'>
20+
<a href='https://github.com/time-rs/time'>
21+
<img src='icons/github.svg' alt='GitHub'>
22+
</a>
23+
</div>
24+
</header>
25+
26+
<main>
27+
<a href='book'>
28+
<img src='icons/book.svg'>
29+
<div class='hover-underline'>Book</div>
30+
</a>
31+
<a href='api/time'>
32+
<img src='icons/code.svg'>
33+
<div class='hover-underline'>Public API</div>
34+
</a>
35+
<a href='internal-api/time'>
36+
<img src='icons/cogs.svg'>
37+
<div class='hover-underline'>Internal API</div>
38+
</a>
39+
</main>
40+
41+
</body>
42+
43+
</html>

website/styles.css

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
* {
2+
padding: 0;
3+
margin: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
:root {
8+
--foreground: #000;
9+
--background: #eee;
10+
11+
color: var(--foreground);
12+
background-color: var(--background);
13+
14+
height: 100%;
15+
width: 100%;
16+
padding: 1.5rem;
17+
}
18+
19+
@media screen and (prefers-color-scheme: dark) {
20+
:root {
21+
--foreground: #fff;
22+
--background: #000;
23+
}
24+
25+
img:not(.no-invert) {
26+
filter: invert(1);
27+
}
28+
}
29+
30+
body {
31+
height: 100%;
32+
width: 100%;
33+
font-size: 2rem;
34+
font-family: monospace;
35+
text-align: center;
36+
37+
display: grid;
38+
grid-template: auto / repeat(3, 1fr);
39+
grid-auto-rows: 1fr;
40+
gap: 2rem;
41+
}
42+
43+
header,
44+
main {
45+
display: contents;
46+
}
47+
48+
.branding {
49+
grid-row: 1;
50+
grid-column: 1 / -1;
51+
}
52+
53+
a {
54+
color: unset;
55+
text-decoration: none;
56+
transition: 150ms;
57+
}
58+
59+
a .hover-underline::after {
60+
content: '';
61+
display: block;
62+
width: 0;
63+
margin: 0 auto;
64+
border-bottom: 1px solid var(--foreground);
65+
transition: width 200ms;
66+
}
67+
68+
a:hover .hover-underline::after {
69+
width: 100%;
70+
transition: width 200ms;
71+
}
72+
73+
header img {
74+
height: 2.5rem;
75+
vertical-align: text-bottom;
76+
}
77+
78+
header .right-box {
79+
grid-row: 1;
80+
grid-column: -2 / -1;
81+
text-align: right;
82+
font-size: 0;
83+
}
84+
85+
header .right-box a:not(:first-of-type) {
86+
margin-left: 2rem;
87+
}
88+
89+
main a {
90+
display: flex;
91+
flex-direction: column;
92+
align-items: center;
93+
justify-content: center;
94+
gap: 1rem;
95+
}
96+
97+
main img {
98+
max-height: 8rem;
99+
max-width: min(8rem, 25vw);
100+
}
101+
102+
@media (max-width: 800px) {
103+
body {
104+
grid-template: auto auto / 1fr;
105+
}
106+
107+
header .right-box {
108+
grid-row: 2;
109+
text-align: center;
110+
}
111+
}

0 commit comments

Comments
 (0)