Skip to content

Commit

Permalink
ci: add build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp-CN committed Dec 2, 2024
1 parent 8be8c9d commit 2f4bdea
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Mdbook build

on:
push:
branches: ["master"]

jobs:
build:
name: build
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
pull-requests: write # To create a PR from that branch
env:
MDBOOK_VERSION: '0.4.40'
# MDBOOK_MERMAID_VERSION: '0.13.0'
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Install mdbook
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir ~/tools
curl -L https://github.com/rust-lang/mdBook/releases/download/v$MDBOOK_VERSION/mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz | tar xz -C ~/tools
# curl -L https://github.com/badboy/mdbook-mermaid/releases/download/v$MDBOOK_MERMAID_VERSION/mdbook-mermaid-v$MDBOOK_MERMAID_VERSION-x86_64-unknown-linux-gnu.tar.gz | tar xz -C ~/tools
gh release download -R Michael-F-Bryan/mdbook-linkcheck -p mdbook-linkcheck.x86_64-unknown-linux-gnu.zip
unzip mdbook-linkcheck.x86_64-unknown-linux-gnu.zip -d ~/tools
chmod +x ~/tools/mdbook-linkcheck
gh release download -R zjp-CN/mdbook-theme -p mdbook-theme_linux.tar.gz
tar -xzf mdbook-theme_linux.tar.gz -C ~/tools
echo ~/tools >> $GITHUB_PATH
- name: Build
run: mdbook build

- name: Upload pages artifacts
uses: actions/upload-pages-artifact@v3
with:
path: book

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action

0 comments on commit 2f4bdea

Please sign in to comment.