Skip to content

Storybook URL check #53

Storybook URL check

Storybook URL check #53

# 週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 Node.js
- name: Setup Node.js environment
uses: actions/setup-node@v4
# Install npm packages
- name: Install dependencies
run: yarn --frozen-lockfile --cwd scripts/content-checker
# リンクチェックの実行
- id: storybookCheck
name: Execute Storybook checker
# エラーが見つかるとスクリプトはexit(1)で終了するが、このactionは中止しない。
# storybookUrlChecker.tsを実行し、`console.log()`と`console.error()`の内容をファイルに出力する
run: |
cd scripts/content-checker && npx ts-node 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