From 906e178dcf8afcdb3201abb7c18313fc94095fc5 Mon Sep 17 00:00:00 2001 From: jamesatomc Date: Sun, 12 Jan 2025 10:34:34 +0700 Subject: [PATCH] Refactor GitHub Actions workflow for documentation deployment: remove old workflow and implement a new streamlined process with Jekyll setup and improved build steps --- .github/workflows/deploy.yml | 78 ------------------------------- .github/workflows/deploy_book.yml | 57 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 78 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/deploy_book.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 622b029..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Deploy Documentation - -on: - push: - branches: - - main - paths: - - 'documentation/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - deploy: - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - - name: Cache Rust dependencies - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/ - ~/.cargo/git/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: Install mdBook - run: | - if ! command -v mdbook &> /dev/null; then - cargo install mdbook mdbook-linkcheck - fi - - - name: Verify links - run: | - cd documentation/book - mdbook test - continue-on-error: true - - - name: Build Documentation - run: | - cd documentation/book - mdbook build - - - name: Check build output - run: | - test -d documentation/book/book || exit 1 - test -f documentation/book/book/index.html || exit 1 - - - name: Configure Jekyll - run: | - echo "theme: jekyll-theme-cayman" > documentation/book/book/_config.yml - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./documentation/book/book - publish_branch: gh-pages - commit_message: "docs: update documentation site [skip ci]" - enable_jekyll: true - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' \ No newline at end of file diff --git a/.github/workflows/deploy_book.yml b/.github/workflows/deploy_book.yml new file mode 100644 index 0000000..dba718a --- /dev/null +++ b/.github/workflows/deploy_book.yml @@ -0,0 +1,57 @@ +name: Deploy Documentation + +on: + push: + branches: [main] + paths: ['documentation/**'] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/ + ~/.cargo/git/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Install mdBook + run: cargo install mdbook mdbook-linkcheck + + - name: Build Documentation + run: | + cd documentation/book + mdbook build + + - name: Setup Jekyll structure + run: | + mkdir -p _site + cp -r documentation/book/book/* _site/ + echo "theme: jekyll-theme-cayman" > _config.yml + echo "title: Kanari SDK Documentation" >> _config.yml + echo "description: Documentation for the Kanari SDK" >> _config.yml + echo "---" > _site/index.html.tmp + echo "layout: default" >> _site/index.html.tmp + echo "---" >> _site/index.html.tmp + cat _site/index.html >> _site/index.html.tmp + mv _site/index.html.tmp _site/index.html + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + enable_jekyll: true + \ No newline at end of file