How to create the initial Home page in a repo Wiki via GitHub Actions? #175621
Replies: 3 comments 1 reply
-
|
This is a known, tricky limitation with GitHub Wikis: the .wiki.git repository does not exist until the Wiki is initialized by a user at least once via the GitHub UI. Your manual testing confirms this behavior. Since there is no official API to force initialization, the only robust workaround is to use a Personal Access Token (PAT) with explicit permissions and a shell script that handles the "repository not found" error by running Recommended Solution: PAT and Initialization ScriptUse a dedicated PAT and the following workflow steps. This script attempts to clone, and if it fails (meaning the Wiki is uninitialized), it initializes a local Git repository which can then perform the first push to the remote. 1. PAT and Secrets
2. Workflow ImplementationUse the following job definition. It uses a robust shell script to handle both initialized and uninitialized Wiki states. ```yaml ``` |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone.
I’m trying to create the very first page (Home.md) in a repository Wiki automatically from a GitHub Actions workflow. I can successfully publish artifacts and update files in the main repo, but I’m stuck at initializing the Wiki and committing the first page from an Action.
What I’ve tried:
Git push to the Wiki repo using a PAT or GITHUB_TOKEN:
Permissions:
Results:
Logs / symptoms
When the Wiki has never been initialized:
Questions:
Is there a known limitation that prevents Actions from creating the very first Wiki page if the Wiki was never initialized via the UI?
Do I need a specific scope (or a different permission than contents: read and write) for pushing to .wiki.git?
Is there a recommended API or Action to initialize the Wiki repo before the first push?
If initialization is required once, is there a non-interactive way to do it purely from a workflow?
Any guidance, examples, or best practices are greatly appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions