New docs - ChunYen-Chen/CheckNode GitHub Wiki
How to create a bi-directional updated wiki
Before getting started, I recommend you have some basic knowledge of repository, branch, fork, action, and workflow.
The following is the outline of this document:
Setup the original repository
-
Create directory
- Create a directory called
wiki_docs
to store the wiki documents.
NOTE: The documents are stored under the directory
wiki_docs
by default. If you want to store the documents under your preference directory, please replace all thewiki_docs
insync-doc-to-wiki.yml
andsync-wiki-to-doc.yml
with your preference directory name. - Create a directory called
-
Copy
sync-doc-to-wiki.yml
andsync-wiki-to-doc.yml
- Copy
sync-doc-to-wiki.yml
andsync-wiki-to-doc.yml
under.github/workflows
.
sync-doc-to-wiki.yml
name: Sync doc to wiki on: workflow_dispatch: env: GIT_AUTHOR_NAME: Actionbot GIT_AUTHOR_EMAIL: [email protected] jobs: job-sync-docs-to-wiki: runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v2 - name: Sync docs to wiki uses: newrelic/wiki-sync-action@main with: source: wiki_docs destination: wiki token: ${{ secrets.TOKEN_FOR_WIKI }} gitAuthorName: ${{ env.GIT_AUTHOR_NAME }} gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }}
sync-wiki-to-doc.yml
name: Sync wiki to doc on: workflow_dispatch: env: GIT_AUTHOR_NAME: Actionbot GIT_AUTHOR_EMAIL: [email protected] jobs: job-sync-wiki-to-docs: runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v2 with: token: ${{ secrets.TOKEN_FOR_WIKI }} # allows us to push back to repo ref: ${{ github.ref_name }} - name: Sync Wiki to Docs uses: newrelic/wiki-sync-action@main with: source: wiki destination: wiki_docs token: ${{ secrets.TOKEN_FOR_WIKI }} gitAuthorName: ${{ env.GIT_AUTHOR_NAME }} gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }} branch: ${{ github.ref_name }}
- Copy
-
Create a token for the action bot
- Go to
Setting
of your account >Developer setting
>Personal access tokens
>Generate new token
- Please check the
repo
and theworkflow
options. - You might want to set the
Expiration
toNo expiration
.
- Go to
-
Create a repository secret token
- Go to
Setting
of the repository >Security
>Secrets and variables
>Actions
>Repository secrets
- Click
New repository secrets
, then you will see the following. Please replace<your personal access token>
to your token atSecret
.
- Go to
-
Congratulations :tada:
- You finish the setup of the bi-directional updated wiki!
Setup forked repository
-
Fork the repository
- Fork the original repository.
-
Create first page
- Click the Wiki page and create the first page
-
Create a token for the action bot
Setting
of your account >Developer setting
>Personal access tokens
>Generate new token
- Please check the
repo
and theworkflow
options.
- Remember to save the token since it will only be shown once!
-
Create a repository secret token
- Go to
Setting
of the repository >Security
>Secrets and variables
>Actions
>Repository secrets
- Click
New repository secrets
, and then you will see the following. Please replace<your personal access token>
to your token atSecret
.
- Go to
-
Enable actions
- Enable workflows to run in the forked repository.
- Click
Actions
> click the green button.
-
Initialize wiki
- Click
Action
>Workflows
>Sync doc to wiki
>Run workflow
> chooseBranch: master
> Click greenRun workflow
. Once the workflow is done, the wiki is also updated to the master version.
- Click
-
Congratulations :tada:
- You finish the setup of the bi-directional updated wiki at the forked repository!
How to use it
We treat the wiki page on GitHub as a local in this method, and we use the workflow to approach the pull
and push
behavior of the wiki.
Change the wiki to the specific branch version
- Click
Action
>Workflows
>Sync doc to wiki
>Run workflow
> choose the specific branch > Click greenRun workflow
. Once the workflow is done, the wiki is also updated to the specific branch version.
Update the wiki content to the specific branch
- Click
Action
>Workflows
>Sync wiki to doc
>Run workflow
> choose the specific branch > Click greenRun workflow
. Once the workflow is done, the docs in the specific branch are updated to the latest wiki.