Storybook URL check #94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 週1回StorybookのURLチェッカーを実行します。 | |
name: Storybook URL check | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '30 2 * * 1' # Monday, 2:30am(UTC+0) | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup pnpm | |
- uses: pnpm/action-setup@v4 | |
# Setup Node.js | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
cache: 'pnpm' | |
# Install packages | |
- name: Install dependencies | |
run: | | |
pnpm install --frozen-lockfile | |
cd ./scripts/content-checker && pnpm install --frozen-lockfile | |
- name: Fetch Storybook Data | |
run: pnpm update:ui-data | |
# リンクチェックの実行 | |
- id: storybookCheck | |
name: Execute Storybook checker | |
working-directory: ./scripts/content-checker | |
# エラーが見つかるとスクリプトはexit(1)で終了するが、このactionは中止しない。 | |
# storybookUrlChecker.tsを実行し、`console.log()`と`console.error()`の内容をファイルに出力する | |
run: | | |
pnpm tsx ./storybookUrlChecker.ts 1>../../output.txt 2>../../errors.txt || true | |
echo errors=`cat ../../errors.txt` >> $GITHUB_OUTPUT | |
- name: Output log to summary | |
# 実行結果をActionsのサマリーに出力 | |
run: | | |
today=$(date "+%Y-%m-%d") | |
echo "### Storybook URL check ${today}" >> $GITHUB_STEP_SUMMARY | |
while read output; do | |
echo "$output" >> $GITHUB_STEP_SUMMARY | |
done <output.txt | |
- name: Output errors to summary | |
# 前のstepでエラーがあった場合はエラーも出力 | |
if: steps.storybookCheck.outputs.errors != '' | |
run: | | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
while read error; do | |
echo "$error" >> $GITHUB_STEP_SUMMARY | |
done <errors.txt | |
echo '```' >> $GITHUB_STEP_SUMMARY |