Skip to content

chore(docs): 自動ドキュメント更新のワークフローを改善 #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/workflows/auto-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,69 @@ on:
- main
paths:
- 'src/**'
workflow_dispatch:

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 "## 概要
--body-file - <<EOF
## 概要
- /srcディレクトリの変更に基づくHonKit ビルドでのドキュメント自動更新 (by GitHub Actions)
- HonKitによるビルド結果を反映

## 確認項目
- [ ] ドキュメントが正しくビルドされていること
"
EOF
else
echo "No changes to commit"
fi