~xdavidwu/xdavidwu.link

a6fd45d8d4f5fef12361b482743de0caf1fbc2b6 — xdavidwu 2 years ago 5588018
move to sourcehut
4 files changed, 61 insertions(+), 72 deletions(-)

A .builds/gemini.yml
A .builds/https.yml
D .gitlab-ci.yml
M _config.yml
A .builds/gemini.yml => .builds/gemini.yml +31 -0
@@ 0,0 1,31 @@
image: alpine/edge
oauth: pages.sr.ht/PAGES:RW
packages:
  - py3-pip
  - hut
tasks:
  - tools: |
      pip3 install md2gemini
      find /lib /usr/lib ~/ -name 'renderers.py' -exec sed -i -E 's/text\.rstrip\(\)\.endswith\("\[" \+ str\(self\.footnote_num\) \+ "\]"\)/False/' {} \;
  - generate: |
      cd xdavidwu.link/_posts
      for i in $(ls -r *.md);do
        OIFS="$IFS"
        IFS=$'\n'
        mv "$i" "${i}.orig"
        while read LINE; do
          F=$(echo "$LINE" | sed 's/^{% include_relative \(.*\) %}$/\1/')
          if [ -f "$F" ]; then
            cat "$F" >> "$i"
          else
            printf "%s\n" "$LINE" >> "$i"
          fi
        done < "${i}.orig"
        IFS=$OIFS
        echo "=> $(echo $i | sed s/\.md$/.gmi/) $(echo $i | cut -f 1-3 -d '-'): $(grep '^title:' $i | cut -f 2 -d \")" >> ../gemini/index.gmi
      done
      md2gemini -w -d ../gemini -a -f -i tab -l paragraph *.md
  - pack: |
      tar -C xdavidwu.link/gemini -cvz . > gemini.tar.gz
  - publish: |
      hut pages publish gemini.tar.gz -d xdavidwu.link -p GEMINI

A .builds/https.yml => .builds/https.yml +27 -0
@@ 0,0 1,27 @@
image: alpine/edge
oauth: pages.sr.ht/PAGES:RW
packages:
  - npm
  - ruby-bundler
  - ruby-jekyll
  - hut
secrets:
  - 6d48e21f-999e-4b3f-b3db-71a77927cc62
tasks:
  - npm: |
      cd xdavidwu.link
      npm ci
      npm run copy-vendor
  - jekyll: |
      cd xdavidwu.link
      bundle install -j $(nproc)
      bundle exec rougify style base16.solarized.dark | sed 's/002b36/202124/g' >> _sass/minimal-mistakes/skins/_custom.scss
      bundle exec rougify style base16.solarized.light >> _sass/minimal-mistakes/skins/_custom-light.scss
      set +x
      export MATRIX_ACCESS_TOKEN=$(cat ~/.matrix_access_token)
      set -x
      bundle exec jekyll build
  - pack: |
      tar -C xdavidwu.link/_site -cvz . > https.tar.gz
  - publish: |
      hut pages publish https.tar.gz -d xdavidwu.link

D .gitlab-ci.yml => .gitlab-ci.yml +0 -69
@@ 1,69 0,0 @@
variables:
  GIT_SUBMODULE_STRATEGY: recursive

gemini:
  stage: build
  image: alpine:latest
  before_script:
    - apk add py3-pip
    - pip3 install md2gemini
    - find /lib /usr/lib ~/ -name 'renderers.py' -exec sed -i -E 's/text\.rstrip\(\)\.endswith\("\[" \+ str\(self\.footnote_num\) \+ "\]"\)/False/' {} \;
  script:
    - cd _posts
    - >
      for i in $(ls -r *.md);do
        OIFS="$IFS"
        IFS=$'\n'
        mv "$i" "${i}.orig"
        while read LINE;do
          F=$(echo "$LINE" | sed 's/^{% include_relative \(.*\) %}$/\1/')
          if [ -f "$F" ];then
            cat "$F" >> "$i"
          else
            printf "%s\n" "$LINE" >> "$i"
          fi
        done < "${i}.orig"
        IFS=$OIFS
        echo "=> $(echo $i | sed s/\.md$/.gmi/) $(echo $i | cut -f 1-3 -d '-'): $(grep '^title:' $i | cut -f 2 -d \")" >> ../gemini/index.gmi
      done
    - md2gemini -w -d ../gemini -a -f -i tab -l paragraph *.md
  artifacts:
    paths:
      - gemini

https:
  stage: build
  image: ruby:alpine
  variables:
    JEKYLL_ENV: production
    LC_ALL: "C.UTF-8"
  before_script:
    - apk add npm
    - npm ci
    - npm run copy-vendor
    - bundle check --path .bundler || apk add git make gcc musl-dev g++
    - mkdir -p .bundler
    - bundle install -j $(nproc) --path .bundler
  script:
    - bundle exec rougify style base16.solarized.dark | sed 's/002b36/202124/g' >> _sass/minimal-mistakes/skins/_custom.scss
    - bundle exec rougify style base16.solarized.light >> _sass/minimal-mistakes/skins/_custom-light.scss
    - bundle exec jekyll build
  artifacts:
    paths:
      - _site
  cache:
    paths:
      - .bundler

deploy:
  stage: deploy
  image: alpine:latest
  before_script:
    - apk add curl
  script:
    - tar -C gemini -cvz . > gemini.tar.gz
    - tar -C _site -cvz . > https.tar.gz
    - curl --oauth2-bearer "$SRHT_PAT" -Fcontent=@gemini.tar.gz -Fprotocol=GEMINI https://pages.xdavidwu.link/publish/xdavidwu.link
    - curl --oauth2-bearer "$SRHT_PAT" -Fcontent=@https.tar.gz -Fprotocol=HTTPS https://pages.xdavidwu.link/publish/xdavidwu.link
  only:
    - master

M _config.yml => _config.yml +3 -3
@@ 26,7 26,7 @@ url: "https://xdavidwu.link" # the base hostname & protocol for your site e.g. "
baseurl: "" # the subpath of your site, e.g. "/blog"
repository: # GitHub username/repo-name e.g. "mmistakes/minimal-mistakes"
since: "2018"
license_url: "https://gitlab.xdavidwu.link/xdavidwu/xdavidwu.xdavidwu.link/-/blob/master/LICENSE"
license_url: "https://git.xdavidwu.link/~xdavidwu/xdavidwu.link/tree/master/item/LICENSE"
teaser: # path of fallback teaser image, e.g. "/assets/images/500x300.png"
logo: # path of logo image to display in the masthead, e.g. "/assets/images/88x88.png"
masthead_title: # overrides the website title displayed in the masthead, use " " for no title


@@ 141,8 141,8 @@ footer:
      icon: "github"
      # url:
    - label: "Source code"
      icon: "gitlab"
      url: "https://gitlab.xdavidwu.link/xdavidwu/xdavidwu.xdavidwu.link"
      icon: "circle-thin"
      url: "https://git.xdavidwu.link/~xdavidwu/xdavidwu.link"
    - label: "Bitbucket"
      icon: "bitbucket"
      # url: