Update website deployment CI script to output auto-generated code docs artifacts (#2849)
This commit is contained in:
parent
e02510303e
commit
ceffcfd8df
|
|
@ -4,7 +4,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request: {}
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
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>
|
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:
|
||||||
build:
|
build:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
deployments: write
|
deployments: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
actions: write
|
||||||
env:
|
env:
|
||||||
RUSTC_WRAPPER: /usr/bin/sccache
|
RUSTC_WRAPPER: /usr/bin/sccache
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
|
|
@ -47,9 +48,11 @@ jobs:
|
||||||
rustc --version
|
rustc --version
|
||||||
|
|
||||||
- name: ✂ Replace template in <head> of index.html
|
- name: ✂ Replace template in <head> of index.html
|
||||||
|
if: github.ref != 'refs/heads/master'
|
||||||
|
env:
|
||||||
|
INDEX_HTML_HEAD_REPLACEMENT: ""
|
||||||
run: |
|
run: |
|
||||||
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
|
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
|
||||||
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT=""
|
|
||||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||||
|
|
||||||
- name: 🌐 Build Graphite web code
|
- name: 🌐 Build Graphite web code
|
||||||
|
|
@ -70,6 +73,19 @@ jobs:
|
||||||
projectName: graphite-dev
|
projectName: graphite-dev
|
||||||
directory: frontend/dist
|
directory: frontend/dist
|
||||||
|
|
||||||
|
- name: 💬 Comment build link URL to commit hash page on GitHub
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
gh api \
|
||||||
|
-X POST \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
/repos/${{ github.repository }}/commits/$(git rev-parse HEAD)/comments \
|
||||||
|
-f body="| 📦 **Build Complete for** $(git rev-parse HEAD) |
|
||||||
|
|-|
|
||||||
|
| ${{ steps.cloudflare.outputs.url }} |"
|
||||||
|
|
||||||
- name: 👕 Lint Graphite web formatting
|
- name: 👕 Lint Graphite web formatting
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
|
@ -91,6 +107,51 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mold -run cargo test --all-features --workspace
|
mold -run cargo test --all-features --workspace
|
||||||
|
|
||||||
|
- name: 📃 Generate code documentation info for website
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: |
|
||||||
|
cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree
|
||||||
|
mkdir -p artifacts-generated
|
||||||
|
mv hierarchical_message_system_tree.txt artifacts-generated/hierarchical_message_system_tree.txt
|
||||||
|
|
||||||
|
- name: 💿 Obtain cache of auto-generated code docs artifacts, to check if they've changed
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
id: cache-website-code-docs
|
||||||
|
uses: actions/cache/restore@v3
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
key: website-code-docs
|
||||||
|
|
||||||
|
- name: 🔍 Check if auto-generated code docs artifacts changed
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
id: website-code-docs-changed
|
||||||
|
run: |
|
||||||
|
if ! diff --brief --recursive artifacts-generated artifacts; then
|
||||||
|
echo "Auto-generated code docs artifacts have changed."
|
||||||
|
rm -rf artifacts
|
||||||
|
mv artifacts-generated artifacts
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Auto-generated code docs artifacts have not changed."
|
||||||
|
rm -rf artifacts
|
||||||
|
rm -rf artifacts-generated
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 💾 Save cache of auto-generated code docs artifacts
|
||||||
|
if: steps.website-code-docs-changed.outputs.changed == 'true'
|
||||||
|
uses: actions/cache/save@v3
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
key: ${{ steps.cache-website-code-docs.outputs.cache-primary-key }}
|
||||||
|
|
||||||
|
- name: ♻️ Trigger website rebuild if the auto-generated code docs artifacts have changed
|
||||||
|
if: steps.website-code-docs-changed.outputs.changed == 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
rm -rf artifacts
|
||||||
|
gh workflow run website.yml --ref master
|
||||||
|
|
||||||
# miri:
|
# miri:
|
||||||
# runs-on: self-hosted
|
# runs-on: self-hosted
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,10 @@ jobs:
|
||||||
rustc --version
|
rustc --version
|
||||||
|
|
||||||
- name: ✂ Replace template in <head> of index.html
|
- name: ✂ Replace template in <head> of index.html
|
||||||
|
env:
|
||||||
|
INDEX_HTML_HEAD_REPLACEMENT: ""
|
||||||
run: |
|
run: |
|
||||||
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
|
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
|
||||||
export INDEX_HTML_HEAD_REPLACEMENT=""
|
|
||||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||||
|
|
||||||
- name: ⌨ Set build command based on comment
|
- name: ⌨ Set build command based on comment
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- website/**
|
- website/**
|
||||||
|
workflow_dispatch: {}
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
INDEX_HTML_HEAD_INCLUSION: <script defer data-domain="graphite.rs" data-api="/visit/event" src="/visit/script.hash.js"></script>
|
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:
|
||||||
with:
|
with:
|
||||||
tool: zola@0.20.0
|
tool: zola@0.20.0
|
||||||
|
|
||||||
|
- name: 🔍 Check if `website/other` directory changed
|
||||||
|
uses: dorny/paths-filter@v3
|
||||||
|
id: changes
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
website-other:
|
||||||
|
- "website/other/**"
|
||||||
|
|
||||||
- name: ✂ Replace template in <head> of index.html
|
- name: ✂ Replace template in <head> of index.html
|
||||||
run: |
|
run: |
|
||||||
# Remove the INDEX_HTML_HEAD_INCLUSION environment variable for build links (not master deploys)
|
# Remove the INDEX_HTML_HEAD_INCLUSION environment variable for build links (not master deploys)
|
||||||
|
|
@ -43,16 +52,8 @@ jobs:
|
||||||
npm run install-fonts
|
npm run install-fonts
|
||||||
zola --config config.toml build --minify
|
zola --config config.toml build --minify
|
||||||
|
|
||||||
- name: 🔍 Check if `website/other` directory changed
|
|
||||||
uses: dorny/paths-filter@v3
|
|
||||||
id: changes
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
other:
|
|
||||||
- "website/other/**"
|
|
||||||
|
|
||||||
- name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change
|
- name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change
|
||||||
if: steps.changes.outputs.other != 'true'
|
if: steps.changes.outputs.website-other != 'true'
|
||||||
id: cache-website-other-dist
|
id: cache-website-other-dist
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -80,8 +81,32 @@ jobs:
|
||||||
|
|
||||||
- name: 🚚 Move `website/other/dist` contents to `website/public`
|
- name: 🚚 Move `website/other/dist` contents to `website/public`
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p website/public
|
||||||
mv website/other/dist/* website/public
|
mv website/other/dist/* website/public
|
||||||
|
|
||||||
|
- name: 💿 Obtain cache of auto-generated code docs artifacts
|
||||||
|
id: cache-website-code-docs
|
||||||
|
uses: actions/cache/restore@v3
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
key: website-code-docs
|
||||||
|
|
||||||
|
- name: 📁 Fallback in case auto-generated code docs artifacts weren't cached
|
||||||
|
if: steps.cache-website-code-docs.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "🦀 Initial system version of Rust:"
|
||||||
|
rustc --version
|
||||||
|
rustup update stable
|
||||||
|
echo "🦀 Latest updated version of Rust:"
|
||||||
|
rustc --version
|
||||||
|
cargo test --package graphite-editor --lib -- messages::message::test::generate_message_tree
|
||||||
|
mkdir artifacts
|
||||||
|
mv hierarchical_message_system_tree.txt artifacts/hierarchical_message_system_tree.txt
|
||||||
|
|
||||||
|
- name: 🚚 Move `artifacts` contents to `website/public`
|
||||||
|
run: |
|
||||||
|
mv artifacts/* website/public
|
||||||
|
|
||||||
- name: 📤 Publish to Cloudflare Pages
|
- name: 📤 Publish to Cloudflare Pages
|
||||||
id: cloudflare
|
id: cloudflare
|
||||||
uses: cloudflare/pages-action@1
|
uses: cloudflare/pages-action@1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue