~scolby33/scolbyblog

ref: 610d2d0981742e37040b43f744a8f384e7501872 scolbyblog/.build.yml -rw-r--r-- 2.7 KiB
610d2d09Scott Colby Touch content files with their git commit time. 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
image: debian/stable
packages:
  - 'fonts-liberation'
  - 'imagemagick'
  - 'npm'
  - 'python3'
  - 'python3-pip'
  - 'python3-setuptools'
  - 'python3-wheel'
  - 'rsync'
artifacts:
  - 'scolbyblog/output.tar.gz'
sources:
  - 'git@git.sr.ht:~scolby33/scolbyblog'
tasks:
  - deps: |
      sudo sed -i -e '/en_US.UTF-8/{s/^# //};p' /etc/locale.gen
      sudo dpkg-reconfigure --frontend noninteractive locales
      sudo update-locale 'en_US.UTF-8'
      mkdir -p ~/.local/bin
      printf 'PATH=~/.local/bin:$PATH\n' >> ~/.buildenv
      npm install --no-progress autoprefixer-cli
      ln -s "$(realpath node_modules/autoprefixer-cli)/autoprefixer-cli" ~/.local/bin/
      cd scolbyblog
      pip3 install --progress-bar off -r requirements.txt
      cd "$(pip3 show markdown | grep '^Location' | cut -d ':' -f2 | xargs)"
      patch markdown/extensions/toc.py ~/scolbyblog/toc.patch
  - build: |
      cd scolbyblog
      git ls-tree -r -z -name-only HEAD content/ \
        | xargs -0 -I {} -R 2 -- \
          git log --date='format:%Y%m%d%H%M.%S' \
            --format='format:%ad%x00{}%x00' -1 -- {} \
        | xargs -0 -n 2 -- touch -t
      pelican --fatal warnings --settings publishconf.py
      tar -czvf output.tar.gz output
  - check-branch: |
      cd scolbyblog
      if test "$(git rev-parse 'main')" != "$(git rev-parse HEAD)"
      then
        echo 'Only deploy from main.'
        complete-build
      fi
  - deploy: |
      printf "ssh.phx.nearlyfreespeech.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJInlNsEgCi/Q2vmF0QJh5F7ZHzrx4oCZIZgr5P1z64Z\n" >> ~/.ssh/known_hosts
      cd scolbyblog
      rm output/assets/{main,pygments}.css
      rsync \
        --info=COPY,DEL,FLIST2,MISC2,NAME,STATS3,SYMSAFE \
        --compress \
        --recursive \
        --delete-after \
        --filter='- .webassets-cache' \
        output/ \
        scolby_scolby@ssh.phx.nearlyfreespeech.net:/home/protected/www.scolby.com/deploy-cache
      hash=$(git rev-parse HEAD)
      ssh scolby_scolby@ssh.phx.nearlyfreespeech.net "
        set -xeuo pipefail
        cd /home/protected/www.scolby.com
        test -d 'releases/www.scolby.com-$hash' && rm -rf 'releases/www.scolby.com-$hash'
        cp -PRp deploy-cache 'releases/www.scolby.com-$hash'
        ln -hsf ../../.htaccess 'releases/www.scolby.com-$hash'
        mkdir 'releases/www.scolby.com-$hash/.well-known'
        ln -hsf ../../../../../public/.well-known/acme-challenge 'releases/www.scolby.com-$hash/.well-known'
        ln -hsf '../protected/www.scolby.com/releases/www.scolby.com-$hash' www.scolby.com
        mv www.scolby.com /home/public
        cd releases && ls -t | tail -n +3 | xargs rm -rvf
      "
secrets:
  - '2ccf0ee2-3429-473d-91c5-bbf637a4be5a'