From 0227bc7aa56dcd98d90a3216f32cabe3ad332230 Mon Sep 17 00:00:00 2001 From: softweitao_37264 Date: Tue, 14 May 2024 16:31:56 +0800 Subject: [PATCH] chore: add github action --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++ .github/workflows/deploy.yml | 46 ++++++++++++++++++++++++++++++++++++ ci/copy-assets.sh | 5 ++++ 3 files changed, 82 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 ci/copy-assets.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3f24c59a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + test: + name: test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust + run: | + rustup set profile minimal + rustup toolchain install stable + rustup default stable + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v2 + with: + mdbook-version: "latest" + - name: Run tests + run: mdbook test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..be43ece4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: Deploy + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +defaults: + run: + shell: bash + +permissions: + contents: write + +jobs: + deploy: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust + run: | + rustup set profile minimal + rustup toolchain install stable + rustup default stable + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v2 + with: + mdbook-version: "latest" + - run: mdbook build + - name: Copy Assets + run: | + chmod +x ci/copy-assets.sh + ci/copy-assets.sh ${{ matrix.os }} + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book diff --git a/ci/copy-assets.sh b/ci/copy-assets.sh new file mode 100644 index 00000000..c29260ee --- /dev/null +++ b/ci/copy-assets.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +cp ./assets/CNAME ./book/ +cp ./assets/*.html ./book/ +cp ./assets/sitemap.xml ./book/ \ No newline at end of file