blog/.drone.yml

114 lines
3.5 KiB
YAML

kind: pipeline
type: docker
name: production
steps:
- name: Modify-Amazon-Links
image: alpine:3.9
commands:
- grep -l -r ecx.images-amazon.com content/ | sort | uniq | xargs -t --no-run-if-empty sed -ie "s/http:\/\/ecx.images-amazon.com/https:\/\/images-na.ssl-images-amazon.com/g"
- grep -l -r "http://www.amazon.co.jp/exec" content/ | sort | uniq | xargs -t --no-run-if-empty sed -i -e "s/http:\/\/www.amazon.co.jp\/exec/https:\/\/www.amazon.co.jp\/exec/g"
- name: hugo
image: cibuilds/hugo:0.83.0
commands:
- sudo hugo -e production --minify -v -s .
- name: Compress-the-Assets
image: alpine:3.9
commands:
- find public/ -type f | egrep "\.(css|js|png|jpg|html|JPG|PNG|CSS|JS|HTML)$" | xargs -n 1 -i% -P 0 sh -c 'cp % %.bk && gzip % && mv %.bk %'
- name: housekeep
image: appleboy/drone-ssh
settings:
host: 10.0.1.166
username: webadm
port: 10022
key:
from_secret: ssh_key
script:
- rm -rf /var/www/blog/*
- rm -rf /home/webadm/works/public/*
- name: scp
image: appleboy/drone-scp
settings:
host: 10.0.1.166
username: webadm
port: 10022
target:
- /var/www/blog
- /home/webadm/works/public
source: public/
key:
from_secret: ssh_key
overwrite: true
strip_components: 1
trigger:
branch:
- master
---
kind: pipeline
type: docker
name: staging
steps:
- name: Modify-Amazon-Links
image: alpine:3.9
commands:
- grep -l -r ecx.images-amazon.com content/ | sort | uniq | xargs -t --no-run-if-empty sed -ie "s/http:\/\/ecx.images-amazon.com/https:\/\/images-na.ssl-images-amazon.com/g"
- grep -l -r "http://www.amazon.co.jp/exec" content/ | sort | uniq | xargs -t --no-run-if-empty sed -i -e "s/http:\/\/www.amazon.co.jp\/exec/https:\/\/www.amazon.co.jp\/exec/g"
- name: generate-ogp-images
image: reg.kazu634.com/kazu634/tcardgen:v0.3
commands:
- wget 'https://github.com/yuru7/HackGen/releases/download/v2.3.0/HackGenNerd_v2.3.0.zip' -O /tmp/font.zip
- unzip /tmp/font.zip -d /tmp/font
- find /tmp/font -type f -name *.ttf | xargs -I% -n 1 cp -p % assets/font/
- find content/ -type f -name '*.md' | grep -v '_index' | xargs -n 1 /usr/local/bin/tcardgen -f assets/font/ -o static/ogp/ -c assets/tcardgen.yaml > /dev/null
- find static/ogp/ -type f -name '*.png' | xargs -I% -n 1 img2webp -lossy -q 50 % -o %.webp > /dev/null
- find static/ogp/ -type f -name '*.png' | xargs --no-run-if-empty rm
- find static/ogp/ -type f -name '*.png.webp' | xargs -n 1 -I% basename % .png.webp | xargs -t -n 1 -I% mv %.png.webp %.png
- name: hugo
image: cibuilds/hugo:0.83.0
commands:
- sudo hugo -e staging --minify -v -s .
- name: Compress-the-Assets
image: alpine:3.9
commands:
- find public/ -type f | egrep "\.(css|js|png|jpg|html|JPG|PNG|CSS|JS|HTML)$" | xargs -n 1 -i% -P 0 sh -c 'cp % %.bk && gzip % && mv %.bk %'
- name: housekeep
image: appleboy/drone-ssh
settings:
host: 10.0.1.166
username: webadm
port: 10022
key:
from_secret: ssh_key
script:
- rm -rf /var/www/test/*
- name: scp
image: appleboy/drone-scp
settings:
host: 10.0.1.166
username: webadm
port: 10022
target: /var/www/test
source: public/
key:
from_secret: ssh_key
overwrite: true
strip_components: 1
trigger:
branch:
exclude:
- master