Skip to content

docs: Update action notes πŸ“š (#83) #296

docs: Update action notes πŸ“š (#83)

docs: Update action notes πŸ“š (#83) #296

Workflow file for this run

# workflow for building and deploying a mdBook site to GitHub Pages
name: Deploy mdBook site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
pull_request:
types:
- opened
- reopened
- synchronize
- closed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# Build job
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "0.4.30"
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-admonish
version: "1.9.0"
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-svgbob2
version: "0.3.0"
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-linkcheck
version: "0.7.7"
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-mermaid
version: "0.12.6"
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-emojicodes
version: "0.2.2"
- name: Update book.toml
if: github.event_name == 'pull_request'
run: |
PR_NUM=${{ github.event.number }}
sed -i "s|site-url = \"/ratatui-book/\"|site-url = \"/ratatui-book/pr-preview/pr-$PR_NUM\"|" ./book.toml
- name: Build with mdBook
run: mdbook build
- name: Deploy preview
if: github.event_name == 'pull_request'
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./book/html
- name: Remove preview
if: github.event_name == 'pull_request' && github.event.action == 'closed'
run: |
PR_NUM=${{ github.event.number }}
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git stash
git fetch origin gh-pages:gh-pages
git checkout gh-pages
git rm -rf pr-preview/pr-$PR_NUM
git commit -m "Remove pr-preview folder (PR $PR_NUM)"
git push origin gh-pages
git checkout "$CURRENT_BRANCH"
git stash pop
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
force_orphan: false
keep_files: true