From 87a7f8660df2382b590257f9d631961847b35447 Mon Sep 17 00:00:00 2001
From: kryota-dev <50436249+kryota-dev@users.noreply.github.com>
Date: Wed, 14 Oct 2026 13:12:35 +0900
Subject: [PATCH 1/3] =?UTF-8?q?ci(setup):=20=E4=BE=9D=E5=AD=98=E3=81=AE?=
=?UTF-8?q?=E6=BA=96=E5=82=99=E3=82=92=20composite=20action=20=E3=81=AB?=
=?UTF-8?q?=E3=81=BE=E3=81=A8=E3=82=81=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
pnpm・Node・install の 3 ステップが ci.yml に 3 回、preview-cleanup.yml に
1 回あったので、.github/actions/setup にまとめる。
install スクリプトは既定で止め(--ignore-scripts)、install-scripts: "true"
のときだけ動かす。トークンを持たない ci ジョブだけが指定し、Preview・本番・
Preview の削除のジョブは既定のままにする。true / false 以外の値は失敗させる。
Refs #30
---
.github/actions/setup/action.yml | 34 +++++++++++++++++++++++++++
.github/workflows/ci.yml | 34 +++++----------------------
.github/workflows/preview-cleanup.yml | 12 ++--------
AGENTS.md | 1 +
docs/deployment.md | 2 +-
5 files changed, 44 insertions(+), 39 deletions(-)
create mode 100644 .github/actions/setup/action.yml
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
new file mode 100644
index 0000000..9932261
--- /dev/null
+++ b/.github/actions/setup/action.yml
@@ -0,0 +1,34 @@
+name: Set up pnpm and Node.js
+description: Install pnpm and Node.js (.node-version) and the dependencies from the lockfile.
+
+inputs:
+ install-scripts:
+ # Jobs that hold deployment credentials leave this off, so no install
+ # script ever runs next to a token.
+ description: '"true" runs the install scripts of dependencies; "false" passes --ignore-scripts.'
+ required: false
+ default: "false"
+
+runs:
+ using: composite
+ steps:
+ - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6
+
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
+ with:
+ node-version-file: .node-version
+ cache: pnpm
+
+ - name: Install dependencies
+ shell: bash
+ run: |
+ case "$INSTALL_SCRIPTS" in
+ true) pnpm install --frozen-lockfile ;;
+ false) pnpm install --frozen-lockfile --ignore-scripts ;;
+ *)
+ echo "install-scripts must be \"true\" or \"false\": $INSTALL_SCRIPTS" >&2
+ exit 1
+ ;;
+ esac
+ env:
+ INSTALL_SCRIPTS: ${{ inputs.install-scripts }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5fbb309..ce59b23 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,15 +24,9 @@ jobs:
with:
persist-credentials: false
- - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6
-
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
+ - uses: ./.github/actions/setup
with:
- node-version-file: .node-version
- cache: pnpm
-
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
+ install-scripts: "true"
- name: Lint (ESLint, Stylelint)
run: pnpm lint
@@ -131,16 +125,8 @@ jobs:
with:
persist-credentials: false
- - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6
-
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
- with:
- node-version-file: .node-version
- cache: pnpm
-
- # Only wrangler is needed here; no install scripts run next to the token.
- - name: Install dependencies
- run: pnpm install --frozen-lockfile --ignore-scripts
+ # Only wrangler is needed here; install scripts stay off next to the token.
+ - uses: ./.github/actions/setup
- name: Download the build
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
@@ -213,16 +199,8 @@ jobs:
with:
persist-credentials: false
- - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6
-
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
- with:
- node-version-file: .node-version
- cache: pnpm
-
- # Only wrangler is needed here; no install scripts run next to the token.
- - name: Install dependencies
- run: pnpm install --frozen-lockfile --ignore-scripts
+ # Only wrangler is needed here; install scripts stay off next to the token.
+ - uses: ./.github/actions/setup
- name: Download the build
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
diff --git a/.github/workflows/preview-cleanup.yml b/.github/workflows/preview-cleanup.yml
index ad5fdd0..f98b6b1 100644
--- a/.github/workflows/preview-cleanup.yml
+++ b/.github/workflows/preview-cleanup.yml
@@ -27,16 +27,8 @@ jobs:
with:
persist-credentials: false
- - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6
-
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
- with:
- node-version-file: .node-version
- cache: pnpm
-
- # Only wrangler is needed here; no install scripts run next to the token.
- - name: Install dependencies
- run: pnpm install --frozen-lockfile --ignore-scripts
+ # Only wrangler is needed here; install scripts stay off next to the token.
+ - uses: ./.github/actions/setup
# The Worker that holds the Previews; see the preview job in ci.yml.
- name: Delete the Preview
diff --git a/AGENTS.md b/AGENTS.md
index 08e7d24..e008dc8 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -23,6 +23,7 @@ pnpm test:lighthouse # Lighthouse CI(Performance ≥ 0.95、他 3 項目 = 1
- Playwright は `pnpm build` 済みの `dist/client` を検査する。ソースを変えたらビルドし直してから走らせる。
- 単一テスト: `pnpm exec playwright test tests/seo.spec.ts`、名前で絞るなら `-g "
"`、プロジェクトを絞るなら `--project=mobile-light`(`{mobile,desktop}-{light,dark}` の 4 つ)。
- CI(`.github/workflows/ci.yml`)は lint → format:check → check → build → test:html → test:links → test:a11y → test:lighthouse の順に走る。PR テンプレートのチェックリストも同じ項目。
+- ワークフローの依存の準備(pnpm・Node・install)は composite action `.github/actions/setup` にまとめてある。install スクリプトは既定で動かさず、品質ゲートのジョブだけが `install-scripts: "true"` で動かす。
## アーキテクチャ
diff --git a/docs/deployment.md b/docs/deployment.md
index 5263ccb..e7c571a 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -21,7 +21,7 @@
2. PR のとき `preview` ジョブ: 1 の artifact を `wrangler preview` で Preview Worker に `pr-<番号>` として上げ、URL を PR にコメントする(同じコメントを更新し続ける)
3. main への push のとき `deploy` ジョブ: 1 の artifact を `wrangler deploy` で本番に上げる
-デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存も `--ignore-scripts` で入れ、トークンのある環境では install スクリプトを動かしません。
+デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存の準備は composite action `.github/actions/setup` が行い、既定では `--ignore-scripts` で入れます。install スクリプトを動かすのは、トークンを持たない `ci` ジョブだけ(`install-scripts: "true"`)です。
デプロイの後には `scripts/check-deployed-headers.mjs` が、配信された URL のレスポンスヘッダーが `dist/client/_headers` の `/*` のルール(CSP を含む)と一致するかを確かめます。デプロイ直後は古い版が応答することがあるため、5 秒間隔で最大 12 回試します(各リクエストのタイムアウトは 10 秒)。workers.dev のホストには `X-Robots-Tag: noindex` があること、kryota.dev には無いことも検査します。
From f882d490d97f4181ab689745736dff79f8c3c5e9 Mon Sep 17 00:00:00 2001
From: kryota-dev <50436249+kryota-dev@users.noreply.github.com>
Date: Wed, 14 Oct 2026 13:12:36 +0900
Subject: [PATCH 2/3] =?UTF-8?q?ci(quality):=20=E5=93=81=E8=B3=AA=E3=82=B2?=
=?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92=E4=B8=A6=E5=88=97=E3=82=B9=E3=83=86?=
=?UTF-8?q?=E3=83=83=E3=83=97=E3=81=A7=E7=B8=AE=E3=82=81=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Playwright のブラウザと lychee を background で入れ、lint・format・
astro check を parallel にする。build は astro check と同じ .astro/ に
書くので、このグループから外す。links と a11y の前で、それぞれ必要な
インストールを wait する(background のステップの GITHUB_PATH は wait
まで反映されない)。
a11y と Lighthouse は直列のままにする。同じマシンで CPU を奪い合うと
Lighthouse の Performance が変動するため。
Refs #30
---
.github/workflows/ci.yml | 49 ++++++++++++++++++++++++++--------------
AGENTS.md | 2 +-
2 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ce59b23..5074a34 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -28,23 +28,17 @@ jobs:
with:
install-scripts: "true"
- - name: Lint (ESLint, Stylelint)
- run: pnpm lint
-
- - name: Format check (Prettier)
- run: pnpm format:check
-
- - name: Type check (astro check)
- run: pnpm check
-
- - name: Build
- run: pnpm build
-
- - name: HTML validation (html-validate)
- run: pnpm test:html
+ # The installs below run in the background while the checks and the
+ # build run; their PATH changes take effect only after a wait step.
+ - id: playwright
+ name: Install Playwright browser
+ background: true
+ run: pnpm exec playwright install --with-deps chromium
# Pinned by version and checksum. The tests below use it as well.
- - name: Install lychee
+ - id: lychee
+ name: Install lychee
+ background: true
run: |
archive="lychee-x86_64-unknown-linux-gnu"
curl --proto "=https" --tlsv1.2 -fsSLo "${RUNNER_TEMP}/lychee.tar.gz" \
@@ -58,15 +52,36 @@ jobs:
LYCHEE_VERSION: 0.24.2
LYCHEE_SHA256: 1f4e0ef7f6554a6ed33dd7ac144fb2e1bbed98598e7af973042fc5cd43951c9a
+ # The build stays out of this group: astro check writes .astro/ as well.
+ - parallel:
+ - name: Lint (ESLint, Stylelint)
+ run: pnpm lint
+
+ - name: Format check (Prettier)
+ run: pnpm format:check
+
+ - name: Type check (astro check)
+ run: pnpm check
+
+ - name: Build
+ run: pnpm build
+
+ - name: HTML validation (html-validate)
+ run: pnpm test:html
+
+ - name: Wait for lychee
+ wait: lychee
+
- name: Link check (lychee, internal links only)
run: pnpm test:links
- - name: Install Playwright browser
- run: pnpm exec playwright install --with-deps chromium
+ - name: Wait for the Playwright browser
+ wait: playwright
- name: Accessibility (axe, light/dark x mobile/desktop)
run: pnpm test:a11y
+ # Not alongside the tests: sharing the CPU skews the scores.
- name: Lighthouse CI
run: pnpm test:lighthouse
diff --git a/AGENTS.md b/AGENTS.md
index e008dc8..4f6ed95 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -22,7 +22,7 @@ pnpm test:lighthouse # Lighthouse CI(Performance ≥ 0.95、他 3 項目 = 1
- Playwright は `pnpm build` 済みの `dist/client` を検査する。ソースを変えたらビルドし直してから走らせる。
- 単一テスト: `pnpm exec playwright test tests/seo.spec.ts`、名前で絞るなら `-g ""`、プロジェクトを絞るなら `--project=mobile-light`(`{mobile,desktop}-{light,dark}` の 4 つ)。
-- CI(`.github/workflows/ci.yml`)は lint → format:check → check → build → test:html → test:links → test:a11y → test:lighthouse の順に走る。PR テンプレートのチェックリストも同じ項目。
+- CI(`.github/workflows/ci.yml`)は lint・format:check・check を並列に走らせた後、build → test:html → test:links → test:a11y → test:lighthouse の順に走る。Playwright のブラウザと lychee は、その裏で入れる。PR テンプレートのチェックリストも同じ項目。
- ワークフローの依存の準備(pnpm・Node・install)は composite action `.github/actions/setup` にまとめてある。install スクリプトは既定で動かさず、品質ゲートのジョブだけが `install-scripts: "true"` で動かす。
## アーキテクチャ
From 82a73e61cb5431ec5bec78f75fb081aee05ea61f Mon Sep 17 00:00:00 2001
From: kryota-dev <50436249+kryota-dev@users.noreply.github.com>
Date: Wed, 14 Oct 2026 13:35:47 +0900
Subject: [PATCH 3/3] =?UTF-8?q?docs(deployment):=20install=20=E3=82=B9?=
=?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=82=92=E5=8B=95=E3=81=8B?=
=?UTF-8?q?=E3=81=99=E3=82=B8=E3=83=A7=E3=83=96=E3=81=AE=E8=AA=AC=E6=98=8E?=
=?UTF-8?q?=E3=82=92=E6=AD=A3=E7=A2=BA=E3=81=AB=E3=81=99=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
ci ジョブにも GITHUB_TOKEN はあるので、持たないのは Cloudflare の
トークンだと書く。
Refs #30
---
docs/deployment.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/deployment.md b/docs/deployment.md
index e7c571a..417a573 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -21,7 +21,7 @@
2. PR のとき `preview` ジョブ: 1 の artifact を `wrangler preview` で Preview Worker に `pr-<番号>` として上げ、URL を PR にコメントする(同じコメントを更新し続ける)
3. main への push のとき `deploy` ジョブ: 1 の artifact を `wrangler deploy` で本番に上げる
-デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存の準備は composite action `.github/actions/setup` が行い、既定では `--ignore-scripts` で入れます。install スクリプトを動かすのは、トークンを持たない `ci` ジョブだけ(`install-scripts: "true"`)です。
+デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存の準備は composite action `.github/actions/setup` が行い、既定では `--ignore-scripts` で入れます。install スクリプトを動かすのは、Cloudflare のトークンを持たない `ci` ジョブだけ(`install-scripts: "true"`)です。
デプロイの後には `scripts/check-deployed-headers.mjs` が、配信された URL のレスポンスヘッダーが `dist/client/_headers` の `/*` のルール(CSP を含む)と一致するかを確かめます。デプロイ直後は古い版が応答することがあるため、5 秒間隔で最大 12 回試します(各リクエストのタイムアウトは 10 秒)。workers.dev のホストには `X-Robots-Tag: noindex` があること、kryota.dev には無いことも検査します。