Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 5 additions & 44 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CI

on:
pull_request:
push:
branches:
- main

permissions:
contents: read
Expand All @@ -14,46 +13,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4

- uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: "latest"

- name: Build mdbook
run: mdbook build --dest-dir out

- name: Cache Cargo registry and Cargo bin
id: cargo-cache
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock','**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install mdbook-utils
if: steps.cargo-cache.outputs.cache-hit != 'true'
run: cargo install mdbook-utils

- name: Generate sitemap
run: mdbook-utils sitemap -o out/sitemap.xml -b https://rsdocsjp.org/ -y

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./out

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
- name: Build Check
uses: ./.github/workflows/build
34 changes: 34 additions & 0 deletions .github/workflows/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs:
using: 'composite'
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install mdbook
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: "latest"

- name: Build mdbook
run: mdbook build --dest-dir out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shellプロパティは必須です.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@hinshiba hinshiba Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run が設定されている場合は必須です。

と書いてあるように見えます

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません...見落としてました。
(なくても動きはするのだが、一応規格上は必須になっているのか...)


- name: Cache Cargo registry and Cargo bin
id: cargo-cache
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock','**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install mdbook-utils
if: steps.cargo-cache.outputs.cache-hit != 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同様にshellプロパティの不足

run: cargo install mdbook-utils

- name: Generate sitemap
run: mdbook-utils sitemap -o out/sitemap.xml -b https://rsdocsjp.org/ -y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同様にshellプロパティの不足

63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy site to Github Pages

on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build-and-commit:
name: Deploy

runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Build Check
uses: ./.github/workflows/build

- name: Move out directory
run: |
mkdir -p tmp/out
mv out tmp/out

- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Preserve specific directories
run: |
mkdir -p preserve
mv out/preview preserve/preview

- name: Adapt new build
run: |
mv -f tmp/out out
mv -f preserve/preview out/preview

- name: Clean
run: |
find . -type f ! -path "./.github/*" ! -path "./out/*" ! -path "./.git/*" -delete

- name: Commit changes to gh-pages branch
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "action@github.com"
git add -N .
set +e
git diff --exit-code --quiet
if [[ $? -eq 1 ]]; then
git add .
git commit -m "Deploy to gh-pages: ${{ github.sha }}"
git push origin gh-pages
fi
40 changes: 40 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy site to Github Pages

on:
push:
branches: ["gh-pages"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
deploy:
name: Deploy

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- name: Checkout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一貫性のためにpreview.ymlと同様にCheckout gh-pagesにしてほしいです.

Suggested change
- name: Checkout
- name: Checkout gh-pages

uses: actions/checkout@v4
with:
ref: gh-pages

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
75 changes: 75 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy PR previews

on:
pull_request:
types: [opened, synchronize, reopened, closed]

permissions:
contents: write
pull-requests: write

concurrency:
group: pr-${{ github.event.pull_request.number }}
cancel-in-progress: true

env:
PAGE_DIR: pr-preview-${{ github.event.pull_request.number }}

jobs:
build-and-commit:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Build Check
uses: ./.github/workflows/build

- name: Move out directory
run: |
mkdir -p tmp/out
mv -f out tmp/out

- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Commit changes to gh-pages branch
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "action@github.com"
mkdir -p out/preview/${{ env.PAGE_DIR }}
mv tmp/out /out/preview/${{ env.PAGE_DIR }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは絶対パスではまずいように思えます.

git add .
git commit -m "Deploy PR preview for #${{ github.event.pull_request.number }}"
git push origin gh-pages

- name: Comment PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Preview deployed to: https://${context.repo.owner}.github.io/preview/${process.env.PAGE_DIR}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

カスタムドメインがあるので

Suggested change
body: `Preview deployed to: https://${context.repo.owner}.github.io/preview/${process.env.PAGE_DIR}`
body: `Preview deployed to: https://rsdocsjp.org/preview/${process.env.PAGE_DIR}`

が正しいと思われます.

})

cleanup:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove preview directory
run: |
rm -rf ./out/preview/${{ env.PAGE_DIR }} || exit 0
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Remove PR preview for #${{ github.event.pull_request.number }}" && git push origin gh-pages || echo "No changes to commit"