What this does
- The workflow (.github/workflows/ai-generate.yml) runs the Node script (scripts/generate-index.js).
- The script calls OpenAI to generate a single-file HTML page and writes it to docs/index.html.
- The workflow then uses peter-evans/create-pull-request to open a PR (branch: ai/auto-index) with the changes so you can review and merge.
Setup
-
Add these files to your repo (paths are as shown).
-
Add a repository secret named
OPENAI_API_KEYwith your OpenAI API key:- Repo → Settings → Secrets and variables → Actions → New repository secret
- Name: OPENAI_API_KEY
- Value: sk-...
-
(Optional) Edit
.github/workflows/ai-generate.ymlto change schedule or TARGET_PATH. -
Trigger the workflow manually (Actions → AI Generate Pages → Run workflow) or wait for the scheduled run.
-
Review and merge the created PR when ready.
-
If you plan to publish via GitHub Pages from the docs folder:
- Settings → Pages → Source: Branch main / folder /docs
Notes and safety
- The Action opens a PR rather than pushing directly, so you can review AI output before merging.
- Keep your OpenAI key secret. GITHUB_TOKEN is provided automatically in Actions and is sufficient for creating PRs.
- You can customize the prompt inside scripts/generate-index.js to tailor the page.