From 6f555ce27380eea4d95e672e02bb77aec74903b8 Mon Sep 17 00:00:00 2001 From: rami3l Date: Fri, 17 Jan 2025 12:43:39 +0800 Subject: [PATCH 1/4] ci(deploy-docs): install `mdbook` with `install-action` --- .github/workflows/deploy-docs.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml index 1b2c532d6f..32b7d46635 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/deploy-docs.yaml @@ -21,10 +21,9 @@ jobs: with: fetch-depth: 0 - name: Install mdbook - run: | - mkdir mdbook - curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook - echo "`pwd`/mdbook" >> $GITHUB_PATH + uses: taiki-e/install-action@v2 + with: + tool: mdbook - name: Build book run: | # Build for stable From 11c7870fba6890ccc3ea9da0d6b6df3d03225399 Mon Sep 17 00:00:00 2001 From: rami3l Date: Fri, 17 Jan 2025 13:55:51 +0800 Subject: [PATCH 2/4] ci(deploy-docs): build one book per workflow step --- .github/workflows/deploy-docs.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml index 32b7d46635..2719b1e2c7 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/deploy-docs.yaml @@ -24,22 +24,28 @@ jobs: uses: taiki-e/install-action@v2 with: tool: mdbook - - name: Build book + - name: Prepare directories + run: | + mkdir -p ${{ runner.temp }}/book + mkdir -p ${{ runner.temp }}/book/devel + mkdir -p ${{ runner.temp }}/book/dev-guide + - name: Build user-guide (stable) run: | - # Build for stable git checkout stable # Support both old and new directory structure during the transition cd doc/user-guide || cd doc mdbook build mv book ${{ runner.temp }} - # Build for master - cd $(git rev-parse --show-toplevel) + - name: Build user-guide (master) + run: | git checkout master cd doc/user-guide mdbook build mv book ${{ runner.temp }}/book/devel - # Build dev-guide for master - cd ../dev-guide + - name: Build dev-guide (master) + run: | + git checkout master + cd doc/dev-guide mdbook build mv book ${{ runner.temp }}/book/dev-guide - name: Deploy to GitHub From 277d5458b01becbc956ff96b4721b8c42b235308 Mon Sep 17 00:00:00 2001 From: rami3l Date: Fri, 17 Jan 2025 12:51:49 +0800 Subject: [PATCH 3/4] ci(deploy-docs): enable on PR without uploads --- .github/workflows/deploy-docs.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml index 2719b1e2c7..b4cc281123 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/deploy-docs.yaml @@ -1,6 +1,10 @@ name: Deploy Docs on: + merge_group: + pull_request: + branches: + - "*" push: branches: - stable @@ -30,6 +34,7 @@ jobs: mkdir -p ${{ runner.temp }}/book/devel mkdir -p ${{ runner.temp }}/book/dev-guide - name: Build user-guide (stable) + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} run: | git checkout stable # Support both old and new directory structure during the transition @@ -49,6 +54,7 @@ jobs: mdbook build mv book ${{ runner.temp }}/book/dev-guide - name: Deploy to GitHub + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} run: | cd ${{ runner.temp }}/book git init From 7c10c101844d32aa560a08478c688e9e7ab2dccc Mon Sep 17 00:00:00 2001 From: rami3l Date: Fri, 17 Jan 2025 14:32:12 +0800 Subject: [PATCH 4/4] ci(deploy-docs): merge with `test-docs` --- .github/workflows/ci.yaml | 40 +++++++++--- .github/workflows/deploy-docs.yaml | 66 -------------------- ci/actions-templates/test-docs-template.yaml | 38 +++++++++-- 3 files changed, 65 insertions(+), 79 deletions(-) delete mode 100644 .github/workflows/deploy-docs.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b138f78864..c8920070d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1517,24 +1517,50 @@ jobs: # stable is placed in the root of the gh-pages branch, while master is placed at /devel doc: # job-name runs-on: ubuntu-latest - if: ${{ contains('["pull_request", "merge_group"]', github.event_name) }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install mdbook + uses: taiki-e/install-action@v2 + with: + tool: mdbook + - name: Prepare directories + run: | + mkdir -p ${{ runner.temp }}/book + mkdir -p ${{ runner.temp }}/book/devel + mkdir -p ${{ runner.temp }}/book/dev-guide + - name: Build user-guide (stable) + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} + run: | + git checkout stable + # Support both old and new directory structure during the transition + cd doc/user-guide || cd doc + mdbook build + mv book ${{ runner.temp }} + - name: Build user-guide (master) run: | - mkdir mdbook - curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook - echo "`pwd`/mdbook" >> $GITHUB_PATH - - name: Build user-guide - run: | + git checkout master cd doc/user-guide mdbook build - - name: Build dev-guide + mv book ${{ runner.temp }}/book/devel + - name: Build dev-guide (master) run: | + git checkout master cd doc/dev-guide mdbook build + mv book ${{ runner.temp }}/book/dev-guide + - name: Deploy to GitHub + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} + run: | + cd ${{ runner.temp }}/book + git init + git config user.name "Deploy from CI" + git config user.email "" + git add . .nojekyll + git commit -m "Deploy $GITHUB_REF $GITHUB_SHA to gh-pages" + git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git push --force --set-upstream origin master:gh-pages # This is ci/actions-templates/conclusion-template.yaml # Do not edit this file in .github/workflows diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml deleted file mode 100644 index b4cc281123..0000000000 --- a/.github/workflows/deploy-docs.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: Deploy Docs - -on: - merge_group: - pull_request: - branches: - - "*" - push: - branches: - - stable - - master - -# Builds all docs for both stable and master branches. -# In the gh-pages branch, we place: -# stable user-guide at / -# master user-guide at /devel -# master dev-guide at /dev-guide - -jobs: - doc: - name: Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install mdbook - uses: taiki-e/install-action@v2 - with: - tool: mdbook - - name: Prepare directories - run: | - mkdir -p ${{ runner.temp }}/book - mkdir -p ${{ runner.temp }}/book/devel - mkdir -p ${{ runner.temp }}/book/dev-guide - - name: Build user-guide (stable) - if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} - run: | - git checkout stable - # Support both old and new directory structure during the transition - cd doc/user-guide || cd doc - mdbook build - mv book ${{ runner.temp }} - - name: Build user-guide (master) - run: | - git checkout master - cd doc/user-guide - mdbook build - mv book ${{ runner.temp }}/book/devel - - name: Build dev-guide (master) - run: | - git checkout master - cd doc/dev-guide - mdbook build - mv book ${{ runner.temp }}/book/dev-guide - - name: Deploy to GitHub - if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} - run: | - cd ${{ runner.temp }}/book - git init - git config user.name "Deploy from CI" - git config user.email "" - git add . .nojekyll - git commit -m "Deploy $GITHUB_REF $GITHUB_SHA to gh-pages" - git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git push --force --set-upstream origin master:gh-pages diff --git a/ci/actions-templates/test-docs-template.yaml b/ci/actions-templates/test-docs-template.yaml index 6f1fd19032..18b58ab418 100644 --- a/ci/actions-templates/test-docs-template.yaml +++ b/ci/actions-templates/test-docs-template.yaml @@ -7,21 +7,47 @@ jobs: # skip-all # stable is placed in the root of the gh-pages branch, while master is placed at /devel doc: # job-name runs-on: ubuntu-latest - if: ${{ contains('["pull_request", "merge_group"]', github.event_name) }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install mdbook + uses: taiki-e/install-action@v2 + with: + tool: mdbook + - name: Prepare directories + run: | + mkdir -p ${{ runner.temp }}/book + mkdir -p ${{ runner.temp }}/book/devel + mkdir -p ${{ runner.temp }}/book/dev-guide + - name: Build user-guide (stable) + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} run: | - mkdir mdbook - curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook - echo "`pwd`/mdbook" >> $GITHUB_PATH - - name: Build user-guide + git checkout stable + # Support both old and new directory structure during the transition + cd doc/user-guide || cd doc + mdbook build + mv book ${{ runner.temp }} + - name: Build user-guide (master) run: | + git checkout master cd doc/user-guide mdbook build - - name: Build dev-guide + mv book ${{ runner.temp }}/book/devel + - name: Build dev-guide (master) run: | + git checkout master cd doc/dev-guide mdbook build + mv book ${{ runner.temp }}/book/dev-guide + - name: Deploy to GitHub + if: ${{ !contains('["pull_request", "merge_group"]', github.event_name) }} + run: | + cd ${{ runner.temp }}/book + git init + git config user.name "Deploy from CI" + git config user.email "" + git add . .nojekyll + git commit -m "Deploy $GITHUB_REF $GITHUB_SHA to gh-pages" + git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git push --force --set-upstream origin master:gh-pages