Skip to content

Commit ec51271

Browse files
committed
Update website deployment CI script to output auto-generated code docs artifacts
1 parent e025103 commit ec51271

File tree

3 files changed

+100
-13
lines changed

3 files changed

+100
-13
lines changed

.github/workflows/build-dev-and-ci.yml

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
7+
pull_request: {}
88
env:
99
CARGO_TERM_COLOR: always
1010
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="dev.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.hash.js"></script>
@@ -13,9 +13,10 @@ jobs:
1313
build:
1414
runs-on: self-hosted
1515
permissions:
16-
contents: read
16+
contents: write
1717
deployments: write
1818
pull-requests: write
19+
actions: write
1920
env:
2021
RUSTC_WRAPPER: /usr/bin/sccache
2122
CARGO_INCREMENTAL: 0
@@ -47,9 +48,11 @@ jobs:
4748
rustc --version
4849
4950
- name: ✂ Replace template in <head> of index.html
51+
if: github.ref != 'refs/heads/master'
52+
env:
53+
INDEX_HTML_HEAD_REPLACEMENT: ""
5054
run: |
5155
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
52-
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT=""
5356
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
5457
5558
- name: 🌐 Build Graphite web code
@@ -70,6 +73,19 @@ jobs:
7073
projectName: graphite-dev
7174
directory: frontend/dist
7275

76+
- name: 💬 Comment build link URL to commit hash page on GitHub
77+
if: github.ref == 'refs/heads/master'
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
gh api \
82+
-X POST \
83+
-H "Accept: application/vnd.github+json" \
84+
/repos/${{ github.repository }}/commits/$(git rev-parse HEAD)/comments \
85+
-f body="| 📦 **Build Complete for** $(git rev-parse HEAD) |
86+
|-|
87+
| ${{ steps.cloudflare.outputs.url }} |"
88+
7389
- name: 👕 Lint Graphite web formatting
7490
env:
7591
NODE_ENV: production
@@ -91,6 +107,51 @@ jobs:
91107
run: |
92108
mold -run cargo test --all-features --workspace
93109
110+
- name: 📃 Generate code documentation info for website
111+
if: github.ref == 'refs/heads/master'
112+
run: |
113+
cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree
114+
mkdir -p artifacts-generated
115+
mv hierarchical_message_system_tree.txt artifacts-generated/hierarchical_message_system_tree.txt
116+
117+
- name: 💿 Obtain cache of auto-generated code docs artifacts, to check if they've changed
118+
if: github.ref == 'refs/heads/master'
119+
id: cache-website-code-docs
120+
uses: actions/cache/restore@v3
121+
with:
122+
path: artifacts
123+
key: website-code-docs
124+
125+
- name: 🔍 Check if auto-generated code docs artifacts changed
126+
if: github.ref == 'refs/heads/master'
127+
id: website-code-docs-changed
128+
run: |
129+
if ! diff --brief --recursive artifacts-generated artifacts; then
130+
echo "Auto-generated code docs artifacts have changed."
131+
rm -rf artifacts
132+
mv artifacts-generated artifacts
133+
echo "changed=true" >> $GITHUB_OUTPUT
134+
else
135+
echo "Auto-generated code docs artifacts have not changed."
136+
rm -rf artifacts
137+
rm -rf artifacts-generated
138+
fi
139+
140+
- name: 💾 Save cache of auto-generated code docs artifacts
141+
if: steps.website-code-docs-changed.outputs.changed == 'true'
142+
uses: actions/cache/save@v3
143+
with:
144+
path: artifacts
145+
key: ${{ steps.cache-website-code-docs.outputs.cache-primary-key }}
146+
147+
- name: ♻️ Trigger website rebuild if the auto-generated code docs artifacts have changed
148+
if: steps.website-code-docs-changed.outputs.changed == 'true'
149+
env:
150+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151+
run: |
152+
rm -rf artifacts
153+
gh workflow run website.yml --ref master
154+
94155
# miri:
95156
# runs-on: self-hosted
96157

.github/workflows/comment-!build-commands.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ jobs:
7373
rustc --version
7474
7575
- name: ✂ Replace template in <head> of index.html
76+
env:
77+
INDEX_HTML_HEAD_REPLACEMENT: ""
7678
run: |
7779
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
78-
export INDEX_HTML_HEAD_REPLACEMENT=""
7980
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
8081
8182
- name: ⌨ Set build command based on comment

.github/workflows/website.yml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
pull_request:
1010
paths:
1111
- website/**
12+
workflow_dispatch: {}
1213
env:
1314
CARGO_TERM_COLOR: always
1415
INDEX_HTML_HEAD_INCLUSION: <script defer data-domain="graphite.rs" data-api="/visit/event" src="/visit/script.hash.js"></script>
@@ -30,6 +31,14 @@ jobs:
3031
with:
3132
tool: zola@0.20.0
3233

34+
- name: 🔍 Check if `website/other` directory changed
35+
uses: dorny/paths-filter@v3
36+
id: changes
37+
with:
38+
filters: |
39+
website-other:
40+
- "website/other/**"
41+
3342
- name: ✂ Replace template in <head> of index.html
3443
run: |
3544
# Remove the INDEX_HTML_HEAD_INCLUSION environment variable for build links (not master deploys)
@@ -43,16 +52,8 @@ jobs:
4352
npm run install-fonts
4453
zola --config config.toml build --minify
4554
46-
- name: 🔍 Check if `website/other` directory changed
47-
uses: dorny/paths-filter@v3
48-
id: changes
49-
with:
50-
filters: |
51-
other:
52-
- "website/other/**"
53-
5455
- name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change
55-
if: steps.changes.outputs.other != 'true'
56+
if: steps.changes.outputs.website-other != 'true'
5657
id: cache-website-other-dist
5758
uses: actions/cache/restore@v3
5859
with:
@@ -80,8 +81,32 @@ jobs:
8081

8182
- name: 🚚 Move `website/other/dist` contents to `website/public`
8283
run: |
84+
mkdir -p website/public
8385
mv website/other/dist/* website/public
8486
87+
- name: 💿 Obtain cache of auto-generated code docs artifacts
88+
id: cache-website-code-docs
89+
uses: actions/cache/restore@v3
90+
with:
91+
path: artifacts
92+
key: website-code-docs
93+
94+
- name: 📁 Fallback in case auto-generated code docs artifacts weren't cached
95+
if: steps.cache-website-code-docs.outputs.cache-hit != 'true'
96+
run: |
97+
echo "🦀 Initial system version of Rust:"
98+
rustc --version
99+
rustup update stable
100+
echo "🦀 Latest updated version of Rust:"
101+
rustc --version
102+
cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree
103+
mkdir artifacts
104+
mv hierarchical_message_system_tree.txt artifacts/hierarchical_message_system_tree.txt
105+
106+
- name: 🚚 Move `artifacts` contents to `website/public`
107+
run: |
108+
mv artifacts/* website/public
109+
85110
- name: 📤 Publish to Cloudflare Pages
86111
id: cloudflare
87112
uses: cloudflare/pages-action@1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy