Link check #50
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回リンクチェッカーを実行します。 | |
name: Link check | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * 1' # Monday, 2am(UTC+0) | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Setup Node.js | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
# Install npm packages | |
- name: Install dependencies | |
run: yarn --frozen-lockfile --cwd scripts/content-checker | |
# リンクチェックの実行 | |
- id: linkCheck | |
name: Execute link checker | |
# リンクエラーが見つかるとスクリプトはexit(1)で終了するが、このactionは中止しない。 | |
# linkChecker.tsを実行し、`console.log()`と`console.error()`の内容をファイルに出力する | |
run: | | |
cd scripts/content-checker && npx ts-node linkChecker.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 "### Link 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.linkCheck.outputs.errors != '' | |
run: | | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
while read error; do | |
echo "$error" >> $GITHUB_STEP_SUMMARY | |
done <errors.txt | |
echo '```' >> $GITHUB_STEP_SUMMARY |