mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-08 00:05:00 +00:00
Add auto deployment infrastructure for website
This commit is contained in:
parent
0a7a69b315
commit
a871ea6d69
9 changed files with 247 additions and 136 deletions
159
.github/workflows/ci.yml
vendored
159
.github/workflows/ci.yml
vendored
|
@ -1,12 +1,12 @@
|
|||
name: Continuous Integration
|
||||
name: "Editor: CI & Dev"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- master
|
||||
env:
|
||||
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.outbound-links.file-downloads.js"></script>
|
||||
|
@ -24,102 +24,95 @@ jobs:
|
|||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🔧 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
|
||||
- name: 🔧 Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: 🟢 Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
|
||||
- name: 🚧 Install Node dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
- name: 🚧 Install Node dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: 🔼 Update Rust to latest stable
|
||||
run: |
|
||||
rustc --version
|
||||
rustup update stable
|
||||
rustc --version
|
||||
- name: 🦀 Update Rust to latest stable
|
||||
run: |
|
||||
rustc --version
|
||||
rustup update stable
|
||||
rustc --version
|
||||
|
||||
- name: Replace template in <head> of index.html
|
||||
run: |
|
||||
# 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
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
run: |
|
||||
# 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
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
|
||||
- name: Publish
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: graphite-dev
|
||||
directory: frontend/dist
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: graphite-dev
|
||||
directory: frontend/dist
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 👕 Lint Graphite web formatting
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
# npm run lint
|
||||
echo "💥 Frontend linting is temporarily disabled until it can be set up again with Svelte 💥"
|
||||
- name: 👕 Lint Graphite web formatting
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
# npm run lint
|
||||
echo "💥 Frontend linting is temporarily disabled until it can be set up again with Svelte 💥"
|
||||
|
||||
- name: 🔬 Check Rust formatting
|
||||
run: |
|
||||
mold -run cargo fmt --all -- --check
|
||||
- name: 🔬 Check Rust formatting
|
||||
run: |
|
||||
mold -run cargo fmt --all -- --check
|
||||
|
||||
- name: 🦀 Build Rust code
|
||||
run: |
|
||||
mold -run cargo build
|
||||
- name: 🦀 Build Rust code
|
||||
run: |
|
||||
mold -run cargo build
|
||||
|
||||
- name: 🧪 Run Rust tests
|
||||
run: |
|
||||
mold -run cargo nextest run
|
||||
- name: 🧪 Run Rust tests
|
||||
run: |
|
||||
mold -run cargo nextest run
|
||||
|
||||
#miri:
|
||||
# runs-on: self-hosted
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
#
|
||||
# - name: 🧪 Run Rust miri
|
||||
# run: |
|
||||
# mold -run cargo +nightly miri nextest run -j32
|
||||
# miri:
|
||||
# runs-on: self-hosted
|
||||
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
|
||||
# - name: 🧪 Run Rust miri
|
||||
# run: |
|
||||
# mold -run cargo +nightly miri nextest run -j32
|
||||
|
||||
cargo-deny:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
checks:
|
||||
- 'crate security advisories'
|
||||
- 'crate license compatibility'
|
||||
|
||||
# Prevent sudden announcement of a new advisory from failing ci:
|
||||
continue-on-error: ${{ matrix.checks == 'crate security advisories' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: EmbarkStudios/cargo-deny-action@v1
|
||||
if: matrix.checks == 'crate security advisories'
|
||||
with:
|
||||
command: check advisories
|
||||
- name: 🔒 Check crate security advisories
|
||||
uses: EmbarkStudios/cargo-deny-action@v1
|
||||
with:
|
||||
command: check advisories
|
||||
|
||||
- uses: EmbarkStudios/cargo-deny-action@v1
|
||||
if: matrix.checks == 'crate license compatibility'
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
- name: 📜 Check crate license compatibility
|
||||
uses: EmbarkStudios/cargo-deny-action@v1
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
|
|
75
.github/workflows/deploy.yml
vendored
75
.github/workflows/deploy.yml
vendored
|
@ -1,9 +1,9 @@
|
|||
name: Deploy release
|
||||
name: "Editor: Production (Latest Stable)"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'latest-stable'
|
||||
- "latest-stable"
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
@ -21,45 +21,46 @@ jobs:
|
|||
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="editor.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script>
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🔧 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
|
||||
- name: 🔧 Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: 🟢 Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
|
||||
- name: 🚧 Install Node dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
- name: 🚧 Install Node dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: 🔼 Update Rust to latest stable
|
||||
run: |
|
||||
rustc --version
|
||||
rustup update stable
|
||||
rustc --version
|
||||
- name: 🦀 Update Rust to latest stable
|
||||
run: |
|
||||
rustc --version
|
||||
rustup update stable
|
||||
rustc --version
|
||||
|
||||
- name: Replace template in <head> of index.html
|
||||
run: |
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
run: |
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
|
||||
- name: Publish
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: graphite-editor
|
||||
directory: frontend/dist
|
||||
branch: master
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: graphite-editor
|
||||
directory: frontend/dist
|
||||
branch: master
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
94
.github/workflows/website.yml
vendored
Normal file
94
.github/workflows/website.yml
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
name: "Website"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- website/**
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- website/**
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="graphite.rs" data-api="/visit/event" src="/visit/script.outbound-links.file-downloads.js"></script>
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🕸 Install Zola
|
||||
uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: zola@0.17.2
|
||||
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
run: |
|
||||
# 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|" website/templates/base.html
|
||||
|
||||
- name: 🌐 Build Graphite website with Zola
|
||||
run: |
|
||||
cd website
|
||||
zola build
|
||||
|
||||
- name: 🔍 Check if `website/other` directory changed
|
||||
uses: dorny/paths-filter@v2
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
other:
|
||||
- "website/other/**"
|
||||
|
||||
- name: 💿 Restore cache of `website/other/dist` directory, if available and `website/other` didn't change
|
||||
if: steps.changes.outputs.other != 'true'
|
||||
id: cache-website-other-dist
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: website/other/dist
|
||||
key: website-other-dist-${{ runner.os }}
|
||||
|
||||
- name: 🟢 Set up Node only if we are going to build in the next step
|
||||
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
|
||||
- name: 📁 Build `website/other` directory only if changed or not cached
|
||||
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
|
||||
id: build-website-other
|
||||
run: |
|
||||
sh website/other/build.sh
|
||||
|
||||
- name: 💾 Save cache of `website/other/dist` directory if it was built above
|
||||
if: steps.cache-website-other-dist.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: website/other/dist
|
||||
key: ${{ steps.cache-website-other-dist.outputs.cache-primary-key }}
|
||||
|
||||
- name: 🚚 Move `website/other/dist` contents to `website/public`
|
||||
run: |
|
||||
mv website/other/dist/* website/public
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: graphite-website
|
||||
directory: website/public
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
Loading…
Add table
Add a link
Reference in a new issue