blog/.drone.yml

121 lines
3.4 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: generate-ogp-images
image: reg.kazu634.com/kazu634/tcardgen
commands:
- find /root -type f -name *.ttf | xargs -t -I% -n 1 cp -p % assets/font/
- find content/ -type f -name '*.md' | grep -v '_index' | xargs -t -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 -n 1 -I% basename % .png | xargs -I% -n 1 img2webp -lossy -q 50 static/ogp/%.png -o static/ogp/%.webp > /dev/null
- find static/ogp/ -type f -name '*.png' | xargs --no-run-if-empty rm
- name: submodules
image: alpine/git
commands:
- git submodule update --init --recursive
- name: hugo
image: cibuilds/hugo:0.115.4
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.222
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.222
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:
- main
---
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: submodules
image: alpine/git
commands:
- git submodule update --init --recursive
- name: hugo
image: cibuilds/hugo:0.115.4
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.222
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.222
username: webadm
port: 10022
target: /var/www/test
source: public/
key:
from_secret: ssh_key
overwrite: true
strip_components: 1
trigger:
branch:
exclude:
- main