Skip to content

Proof of concept repo for controlling a Wiki with another repo

Notifications You must be signed in to change notification settings

rfearing/wiki-test-wiki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Wiki circleci Integration Example.

This is a proof of concept. The current repo controls this repo's wiki page. GitHub Wikis are great. According to GitHub:

  • README files are a quick and simple way for other users to learn more about your work.
  • Wikis on GitHub help you present in-depth information about your project in a useful way.
  • It’s a good idea to at least have a README on your project, because it’s the first thing many people will read when they first find your work.

Wikis can be forked and pulled down to edit locally, but the main problem, however, arises if you're working with a team. You can't submit a PR to your wiki.

This concept addresses that issue. Before beginning, you'll need to have signed up for circleci or have your organization sign up for circleci.

Steps to introduce into your project's wiki:

  1. git clone <repo wiki url> (see screenshot below)
  2. Rename with <repo.wiki> to -wiki
    • e.g. mv example-project to example-project-wiki
  3. Create an empty repo in github (with the same name as you renamed above)
  4. Remove original repo origin
    • git remote remove origin
  5. Add the new origin
    • git remote add origin <new repo url>
  6. Generate a GitHub personal access token with write access to the project in the original repo. See GitHub Docs and screenshot below.
  7. Add your new repo as a circleci Project, in the circleci Dashboard. See circleci Docs
  8. In your circleci Project, add the following environment variables:
    • GITHUB_EMAIL: The GitHub Account Email you created the Personal Access Token with.
    • GITHUB_USERNAME: The GitHub Account Username you created the Personal Access Token with.
    • GITHUB_API_KEY: The Personal Access Token from GitHub
  9. Add a .circleci directory and a config.yml file in that directory locally.
  10. Fill the config with following. (Note that any output generated by the command is redirected to /dev/null so that secrets never show up in the build log.). You can see this config as an example.
    version: 2.1
    description: Automatically build and push to your GitHub Repo Wiki
    
    jobs:
      build:
        docker:
          - image: circleci/node
        steps:
          - checkout
          - run:
              name: Push Wiki To Project Wiki
              command: |
                git config user.email "${GITHUB_EMAIL}"
                git config user.name "${GITHUB_USERNAME}"
                git remote remove origin
                git remote add origin https://${GITHUB_API_KEY}@github.com/<github-username>/<original-repo-wiki.git> > /dev/null 2>&1
                git push origin master > /dev/null 2>&1
    
    workflows:
      main:
        jobs:
          - build:
              filters:
                branches:
                  only: master
  11. Push to your new repo.
    • git add .
    • git commit -m "Add circleCI config"
    • git push -u origin master

Now What?

Now, users can submit Pull Requests onto your new repo. If merged into master, changes will be pushed to the original repo's wiki. One thing to note, that if you rewrite history, this will fail. You can change:

  • git push origin master > /dev/null 2>&1

to

  • git push origin master -f > /dev/null 2>&1

in the config.yml file to allow for rewriting history.

Screenshots:

Clone Wiki:

Screenshot of Wiki Clone

CircleCI Add Project:

Screenshot of adding circleCI project

GitHub Personal Access Token:

Screenshot of adding personal access token

About

Proof of concept repo for controlling a Wiki with another repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages