mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Feat: Host Documentation for multiple versions/branch (#188)
* Better Docs * Made action only to run on `main` or version branch * Moved README.md to BRANCHES.md * Redirect to main branch by default * Moved Branches.md to branches.html
This commit is contained in:
parent
0d16f01571
commit
9ef53fcf2b
1 changed files with 63 additions and 27 deletions
90
.github/workflows/doc.yml
vendored
90
.github/workflows/doc.yml
vendored
|
@ -1,45 +1,81 @@
|
||||||
name: Doc
|
name: Generate Documentation
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- '*.*.*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: "pages"
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
environment:
|
|
||||||
name: github-pages
|
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
uses: rs-workspace/rust-toolchain@v0.1.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
- run: cargo doc --workspace --no-deps
|
|
||||||
- uses: "finnp/create-file-action@master"
|
- name: Generate Documentation
|
||||||
env:
|
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --workspace --no-deps
|
||||||
FILE_NAME: "./target/doc/index.html"
|
|
||||||
FILE_DATA: '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;url=''./azalea''"/></head></html>' # Redirect to default page
|
- name: Prepare Documentation
|
||||||
|
run: |
|
||||||
- name: Setup Pages
|
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '/' '_') # Get branch name safely
|
||||||
uses: actions/configure-pages@v2
|
mkdir -p versioned_docs/$BRANCH_NAME
|
||||||
- name: Upload artifact
|
cp -r target/doc/* versioned_docs/$BRANCH_NAME
|
||||||
uses: actions/upload-pages-artifact@v1
|
|
||||||
with:
|
- name: Checkout to Docs Branch
|
||||||
path: './target/doc/'
|
run: |
|
||||||
- name: Deploy to GitHub Pages
|
git config --global user.name "github-actions[bot]"
|
||||||
id: deployment
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
uses: actions/deploy-pages@v1
|
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 branches.html
|
||||||
|
run: |
|
||||||
|
VERSIONS=$(ls -d */ | sed 's#/##' | sort -r) # Get all version directories and sort them (latest first)
|
||||||
|
echo "<!DOCTYPE html>" > branches.html
|
||||||
|
echo "<html lang=\"en\">" >> branches.html
|
||||||
|
echo "<head>" >> branches.html
|
||||||
|
echo " <meta charset=\"UTF-8\">" >> branches.html
|
||||||
|
echo " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" >> branches.html
|
||||||
|
echo " <title>Azalea Docs</title>" >> branches.html
|
||||||
|
echo "</head>" >> branches.html
|
||||||
|
echo "<body>" >> branches.html
|
||||||
|
echo " <h1>Azalea Docs</h1>" >> branches.html
|
||||||
|
echo " <p>Welcome to the documentation for Azalea Crate.</p>" >> branches.html
|
||||||
|
echo " <h2>Available Versions</h2>" >> branches.html
|
||||||
|
echo " <ul>" >> branches.html
|
||||||
|
|
||||||
|
# Update branches.html with available versions
|
||||||
|
for VERSION in $VERSIONS; do
|
||||||
|
echo " <li><a href=\"https://azalea.matdoes.dev/$VERSION/index.html\">$VERSION</a></li>" >> branches.html
|
||||||
|
done
|
||||||
|
|
||||||
|
echo " </ul>" >> branches.html
|
||||||
|
echo "</body>" >> branches.html
|
||||||
|
echo "</html>" >> branches.html
|
||||||
|
|
||||||
|
echo "branches.html generated successfully."
|
||||||
|
|
||||||
|
- name: Create Index Page
|
||||||
|
run: |
|
||||||
|
if [ ! -f index.html ]; then
|
||||||
|
echo "<meta http-equiv=refresh content=0;url=main/azalea>" > index.html
|
||||||
|
fi
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue