Merge branch 'change-ci' of kazu634/blog into master

This commit is contained in:
Kazuhiro MUSASHI 2020-01-19 15:49:04 +09:00 committed by Gitea
commit cc75c68842
5 changed files with 102 additions and 74 deletions

View File

@ -1,60 +0,0 @@
version: 2
jobs:
build:
docker:
- image: cibuilds/hugo:latest
steps:
- checkout
- run:
name: Change Amazon Links
working_directory: /root/project/
command: |
set +o pipefail
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"
- run:
name: "Run Hugo"
working_directory: /root/project/
command: |
if [ "${CIRCLE_BRANCH}" != "master" ]; then
hugo -e staging -v -s /root/project/
else
hugo -e production -v -s /root/project/
fi
- run:
name: Change Amazon Links
working_directory: /root/project/
command: |
set +o pipefail
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"
- run:
name: "Gzip css/js/images"
working_directory: /root/project/
command: |
for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`
do
gzip -c ${TARGET} > ${TARGET}.gz
done
- add_ssh_keys:
fingerprints:
- "7d:eb:56:da:3f:71:e1:fd:2f:c1:86:18:fe:08:8b:f9"
- run:
name: Start ssh-keyscan
command: |
ssh-keyscan -p ${SSHPORT} ${HOST_NAME} >> ~/.ssh/known_hosts
- run:
name: Deploy
command: |
if [ "${CIRCLE_BRANCH}" != "master" ]; then
ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/test/*"
rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/test
else
ssh -p ${SSHPORT} ${USER_NAME}@${HOST_NAME} "rm -rf /var/www/blog/*"
rsync -e "ssh -p ${SSHPORT}" --omit-dir-times -rltvz --delete public/ ${USER_NAME}@${HOST_NAME}:/var/www/blog
fi

79
.drone.yml Normal file
View File

@ -0,0 +1,79 @@
kind: pipeline
type: docker
name: production
steps:
- name: Modify-Amazon-Links
image: cibuilds/hugo:0.62.1
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.62.1
commands:
- hugo -e production -v -s .
- name: Compress-the-Assets
image: cibuilds/hugo:0.62.1
commands:
- for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`; do gzip -c ${TARGET} > ${TARGET}.gz; done
- for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`; do rm -f ${TARGET}; done
- name: scp
image: appleboy/drone-scp
settings:
host: 10.0.1.166
username: webadm
port: 10022
target: /var/www/blog
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: cibuilds/hugo:0.62.1
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.62.1
commands:
- hugo -e staging -v -s .
- name: Compress-the-Assets
image: cibuilds/hugo:0.62.1
commands:
- for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`; do gzip -c ${TARGET} > ${TARGET}.gz; done
- for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`; do rm -f ${TARGET}; done
- 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

View File

@ -11,3 +11,7 @@ theme = "angels-ladder"
profile = "/images/profile.png"
analytics = "UA-57665492-1"
copyright = "Written by Kazuhiro MUSASHI"
[markup.goldmark.renderer]
unsafe = true

View File

@ -11,3 +11,6 @@ theme = "angels-ladder"
profile = "/images/profile.png"
analytics = "UA-57665492-1"
copyright = "Written by Kazuhiro MUSASHI"
[markup.goldmark.renderer]
unsafe = true

View File

@ -5,20 +5,22 @@
-->
<main id="index" role="main">
<div class="article-header light-gray"><h1>Recent Articles</h1></div>
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "post") }}
{{ range $paginator.Pages }}
<div class="summary">
<h2><a href="{{ .Permalink }}">{{ .Title }} {{ if .Draft }}:: DRAFT{{end}}</a></h2>
<div class="meta">
{{ .Date.Format "Jan 2, 2006" }} &nbsp;
{{ range .Params.categories }}
#<a href="/categories/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
{{ range .Params.tags }}
#<a href="/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}: {{ .Description }}
</div>
</div>
{{ if eq .Kind "page" }}
<div class="summary">
<h2><a href="{{ .Permalink }}">{{ .Title }} {{ if .Draft }}:: DRAFT{{end}}</a></h2>
<div class="meta">
{{ .Date.Format "Jan 2, 2006" }} &nbsp;
{{ range .Params.categories }}
#<a href="/categories/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
{{ range .Params.tags }}
#<a href="/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}: {{ .Description }}
</div>
</div>
{{ end }}
{{ end }}
</main>
@ -26,7 +28,7 @@
<!-- Paginator Section Layout
-->
<nav>
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ $paginator := .Paginate (where .Site.Pages "Type" "post") }}
{{ if .Paginator.HasPrev }}
<a href="{{ .Paginator.Prev.URL }}">Prev</a>
{{ end }}