How to setup an asciidoc blog
install ruby 3.x
-
update the packages on the system:
sudo apt-get update sudo apt-get upgrade
-
installation through Rbenv:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
alternatively, add below code to ~/.profile
if [ -d "$HOME/.rbenv/bin" ] ; then
PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
-
install ruby programming language using the commands:
rbenv install 3.1.2
rbenv global 3.1.2
install jekyll
gem install bundler
gem install jekyll
Also, you may want to change the ruby mirrors by,
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
gem sources -l
bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems
create a jekyll blog
jekyll new <your new jekyll blog dirs>
cd <alt+.>
create github action
github page provided jekyll workflow template, create one.
# see https://github.com/actions/starter-workflows/blob/main/pages/jekyll.yml for reference
name: Publish to GitHub Pages
on:
push:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: "pages"
cancel-in-progress: false
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pull-requests: write
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.CI_TOKEN }}
submodules: true
- name: Git Submodule Update
run: |
git pull --recurse-submodules
git submodule update --remote --recursive
- name: Commit update
run: |
git config --global user.name 'Git bot'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.CI_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Auto updated submodule references" && git push || echo "No changes to commit"
- name: Install Ruby and Jekyll
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42
with:
ruby-version: '3.2'
bundler-cache: true
cache-version: 0
- name: Configure Pages
id: pages
uses: actions/configure-pages@v4
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Generate Site
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: "production"
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v3
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
the CI_TOKEN
is your repository secrets, and the content is your github access token.
link your private asciidoc repo with submodules
If you don't want to show your asciidoc , just link it to `_posts` pages.
git submodule add --force git@github.com:<domain>/<asciidocrepo>.git _posts
add a bot to deploy it recursively.
github/dependbot.yml
version: 2
updates:
- package-ecosystem: gitsubmodule
schedule:
interval: daily
directory: /
deploy and setup HTTPs domain
<omit>