chore(docs): 自動ドキュメント更新のワークフローを改善 #18
Workflow file for this run
This file contains hidden or 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
name: Auto Documentation Update | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/**' | ||
jobs: | ||
build-docs: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
cache: 'yarn' | ||
- name: Install dependencies | ||
run: yarn install | ||
- name: Build documentation | ||
run: yarn build | ||
- name: Verify build result | ||
run: | | ||
if [ ! -f "docs/index.html" ]; then | ||
echo "Error: Documentation build failed" | ||
exit 1 | ||
fi | ||
echo "✅ Documentation built successfully" | ||
- name: Create Pull Request | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
timestamp=$(date +%Y%m%d%H%M%S) | ||
branch_name="docs/$timestamp-update" | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git checkout -b "$branch_name" | ||
git add docs/ | ||
git reset -- docs/CNAME | ||
if ! git diff --cached --quiet; then | ||
git commit -m "chore(docs): HonKit ビルドによるドキュメント更新" | ||
git push origin "$branch_name" | ||
gh pr create \ | ||
--base main \ | ||
--head "$branch_name" \ | ||
--title "chore(docs): HonKit ビルドによるドキュメント更新" \ | ||
--body-file - <<EOF | ||
## 概要 | ||
- /srcディレクトリの変更に基づくHonKit ビルドでのドキュメント自動更新 (by GitHub Actions) | ||
- HonKitによるビルド結果を反映 | ||
## 確認項目 | ||
- [ ] ドキュメントが正しくビルドされていること | ||
EOF | ||
else | ||
echo "No changes to commit" | ||
fi |