Explain Instructions Setup
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.
Submodules
The 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.
-
forumsBotControlPanel The
forumsBotControlPanel
is in thecontrolPanel
folder in theforumsBot
repo. 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. -
forumsBotInstructions The
forumsBotInstructions
duplicates 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 theinstructions
folder in theforumsBot
repo. These files are put into your git repo and displayed on GitHub pages.
The instructions
pull their information from a file called instructions.json
. instructions.json
is located in the instructions/src
folder. instructions.json
is generated from information from the config.json
file in the root of forumsBot
and also information pulled from the forums.
GitHub Pages
The instructions setup script does the following steps:
-
It changes the
package.json
file ininstructions
. It changes thehomepage
property to the GitHub pages url of your repo. -
It sets the remote origin url of
instructions
to your repo instead of the originalforumsBotInstructions
repo url. That means that when files are changed and theinstructions
submodule is pushed, the new files will be pushed to your repo. -
It generates the instructions by reading the
config.json
file in theforumsBot
root folder and by fetching information from the forums. It then saves the instructions asinstructions.json
in thesrc
folder insideinstructions
. The instructions website will read from thisinstructions.json
file and display the information. -
It runs the npm
deploy
script in thepackage.json
file ininstructions
. Thedeploy
script is set to run a GitHub Pages command,gh-pages -d build
. This command takes the files that make up the React project ininstructions
and turns them into static files that can be hosted on GitHub pages. Then it pushes the static files to a branch namedgh-pages
in your repo. -
GitHub pages takes the files from the
gh-pages
branch of your repo and serves them as a website.
Updating
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.json
file in theinstructions
module and push the updates to thegh-pages
branch 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 scriptuploadInstructions
.
$ 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.