分散システムとポエム

Creating Private Wiki by mkdocs + GitLab CI + Heroku

I was looking for private wiki written by Markdown. This post introduces how to create a private wiki by mkdocs + GitLab CI + Heroku.

mkdocs

“mkdocs” is a simple document builder and converts documents in markdown to HTML. One of the famous themes is “material.”

mkdocs.yaml

site_name: Notebook
theme:
  name: 'material'
  language: 'ja'
extra:
  search:
    language: 'ja'

GitLab CI

Putting a config file .gitlab-ci.yaml in the root path in git repository.

.gitlab-ci.yaml

build-mdfiles:
  image: python:3.7-alpine
  stage: build
  script:
    - pip install -r requirements.txt
    - mkdocs build
    # test
    - apk add git
    - git clone --depth 1 https://github.com/nulltask/heroku-static-provider.git static-site
    - cd static-site/
    - git config user.email 'koya@koyama.me'
    - git config user.name 'koya'
    - git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APPNAME.git
    - git pull heroku master
    - cp -r ../site/* public/
    - git add .
    - git commit -a -m `date +deploy_%Y%M%d_%H%m%S`
    - git push heroku master

Setting secret variables on Repository.
Settings => CI/CD => Variables

GitLab Setting

Heroku

Following these steps:

  1. Create Heroku account
  2. Setup Heroku CLI ENV
  3. Create a site on Heroku
    1. heroku create
  4. Optional: If you wish to use BasicAuth, you should run these commands.
    1. heroku config:set -a=koyawiki USER=YOUR_USER
    2. heroku config:set -a=koyawiki PASS=YOUR_PASS

On Merge Request created

Running CI
CI Console
Build Wiki

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です