fix: Syntax highlighting when deployed #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [ "master" ] | |
env: | |
CARGO_TERM_COLOR: always | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
build_site: | |
name: Build site | |
runs-on: ubuntu-latest | |
steps: | |
# - name: Setup Rust toolchain | |
# uses: actions-rs/toolchain@v1 | |
# with: | |
# toolchain: nightly | |
# target: x86_64-unknown-linux-gnu | |
# default: true | |
# profile: default | |
- name: Checkout codebase | |
uses: actions/checkout@v4 | |
- name: Check the current Grass version | |
run: | | |
curl https://crates.io/api/v1/crates/grass > grass_rev | |
- name: Restore Cargo cache | |
id: cache-cargo | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo | |
key: ${{ runner.os }}-cargo-${{ hashFiles('src/**/*', '.cargo/**/*', 'Cargo.toml', 'rust-toolchain.toml', 'grass_rev') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ hashFiles('src/**/*', '.cargo/**/*', 'Cargo.toml', 'rust-toolchain.toml', 'grass_rev') }} | |
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} | |
name: Install Vox and Grass | |
run: | | |
rustup update nightly && rustup default nightly | |
time cargo install --path . --features="cli" | |
time cargo install grass | |
- name: Generate documentation | |
run: time cargo doc --no-deps -Zrustdoc-map --release --quiet | |
- name: Build site | |
run: | | |
rm grass_rev | |
mkdir -p site/output | |
cp -r target/doc/* site/output/ | |
cd site | |
./prebuild.sh | |
vox build -d -s | |
cd ../ | |
- name: Fix permissions | |
run: | | |
chmod -c -R +rX "target/doc/" | while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "site/output/" | |
deploy_site: | |
needs: build_site | |
name: Deploy to GitHub Pages | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
apply_suggestions: | |
name: Format code, apply compiler suggestions | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v4 | |
- name: Setup Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
components: clippy, rustfmt | |
profile: minimal | |
- name: Format | |
run: cargo fmt | |
- name: Apply compiler suggestions | |
run: | | |
cargo fix --edition --edition-idioms --allow-dirty | |
cargo clippy --fix -Z unstable-options --allow-dirty | |
cargo fix --edition --edition-idioms --bin vox --features="cli" --allow-dirty | |
cargo clippy --fix -Z unstable-options --bin vox --features="cli" --allow-dirty | |
- name: Commit changes to code, if any | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git diff --quiet && git diff --staged --quiet || git commit -am "chore: Format and apply compiler suggestions." | |
git push |