mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 23:44:38 +00:00
61 lines
2 KiB
YAML
61 lines
2 KiB
YAML
name: Generate Documentation
|
|
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Rust Toolchain
|
|
uses: rs-workspace/rust-toolchain@v0.1.0
|
|
with:
|
|
toolchain: nightly
|
|
|
|
- name: Generate Documentation
|
|
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --workspace --no-deps
|
|
|
|
- name: Prepare Documentation
|
|
run: |
|
|
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '/' '_') # Get branch name safely
|
|
mkdir -p versioned_docs/$BRANCH_NAME
|
|
cp -r target/doc/* versioned_docs/$BRANCH_NAME
|
|
|
|
- name: Checkout to Docs Branch
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git fetch origin docs || git checkout --orphan docs
|
|
git checkout docs
|
|
cp -r versioned_docs/* ./ # Copy docs to branch root
|
|
rm -rf versioned_docs # Clean up
|
|
rm -rf target # Clean up
|
|
|
|
- name: Generate README.md
|
|
run: |
|
|
VERSIONS=$(ls -d */ | sed 's#/##' | sort -r) # Get all version directories and sort them (latest first)
|
|
rm README.md # Delete README.md and generate a new one
|
|
echo "# Azalea Docs" > README.md
|
|
echo "Welcome to the documentation for Azalea Crate." >> README.md
|
|
echo "" >> README.md
|
|
|
|
# Update README.md with available versions
|
|
echo "## Available Versions" >> README.md
|
|
for VERSION in $VERSIONS; do
|
|
echo "- [$VERSION](./$VERSION/index.html)" >> README.md
|
|
done
|
|
|
|
echo "README.md updated successfully."
|
|
|
|
- name: Deploy Documentation to Docs Branch
|
|
run: |
|
|
git add .
|
|
git commit -m "Update documentation for $GITHUB_REF_NAME" || echo "No changes to commit"
|
|
git push origin docs
|