What Does the setupHostedInstructions Script Do?
The script sets up the bot instructions page to be pushed to the blank repo you just made. The page will be hosted on GitHub pages.
forumsBot repo has two other repos inside it as Git submodules. When you clone
forumsBot you also clone the submodules, the instructions and the controlPanel.
forumsBotControlPanelis in the
controlPanelfolder in the
forumsBotrepo. The control panel shows instructions, the log viewer, and lets you control the actions of the bot and change its settings. It just runs locally.
forumsBotInstructionsduplicates the instructions display part of the control panel. It is designed to be public facing and cannot access any confidential information. The files for this submodule are in the
instructionsfolder in the
forumsBotrepo. These files are put into your git repo and displayed on GitHub pages.
instructions pull their information from a file called
instructions.json is located in the
instructions.json is generated from information from the
config.json file in the root of
forumsBot and also information pulled from the forums.
The instructions setup script does the following steps:
It changes the
instructions. It changes the
homepageproperty to the GitHub pages url of your repo.
It sets the remote origin url of
instructionsto your repo instead of the original
forumsBotInstructionsrepo url. That means that when files are changed and the
instructionssubmodule is pushed, the new files will be pushed to your repo.
It generates the instructions by reading the
config.jsonfile in the
forumsBotroot folder and by fetching information from the forums. It then saves the instructions as
instructions. The instructions website will read from this
instructions.jsonfile and display the information.
It runs the npm
deployscript in the
deployscript is set to run a GitHub Pages command,
gh-pages -d build. This command takes the files that make up the React project in
instructionsand turns them into static files that can be hosted on GitHub pages. Then it pushes the static files to a branch named
gh-pagesin your repo.
GitHub pages takes the files from the
gh-pagesbranch of your repo and serves them as a website.
The instructions on the GitHub pages website won’t update automatically. But you can update them two ways.
Using the Control Panel Run the control panel. Click the ‘save’ icon in the TopBar of the controlPanel. This will update the
instructions.jsonfile in the
instructionsmodule and push the updates to the
gh-pagesbranch of your repo. The changes will then be visible on the instructions website.
Using the Command Line Navigate to the root folder of the
forumsBot. Run the npm script
$ npm run uploadInstructions
The script will update the
instructions.json file in the
instructions module and push the updates to the
gh-pages branch of your repo. The changes will then be visible on the instructions website.