2019-05-04 10:29:17 +00:00
|
|
|
version: 2
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
docker:
|
2019-05-04 10:49:22 +00:00
|
|
|
- image: cibuilds/hugo:latest
|
2019-05-04 10:29:17 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout
|
2019-05-04 12:39:59 +00:00
|
|
|
- run:
|
|
|
|
name: Change Amazon Links
|
2019-05-04 12:43:13 +00:00
|
|
|
working_directory: /root/project/
|
2019-05-04 12:39:59 +00:00
|
|
|
command: |
|
2019-05-04 12:51:31 +00:00
|
|
|
set +o pipefail
|
2019-05-04 12:39:59 +00:00
|
|
|
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"
|
|
|
|
|
2019-05-04 10:29:17 +00:00
|
|
|
- run:
|
2019-05-04 10:49:22 +00:00
|
|
|
name: "Run Hugo"
|
2019-05-04 12:43:13 +00:00
|
|
|
working_directory: /root/project/
|
2019-05-04 14:01:41 +00:00
|
|
|
command: |
|
|
|
|
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
|
|
|
hugo -e staging -v -s /root/project/
|
|
|
|
else
|
|
|
|
hugo -e production -v -s /root/project/
|
|
|
|
fi
|
2019-05-04 12:39:59 +00:00
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Change Amazon Links
|
2019-05-04 12:43:13 +00:00
|
|
|
working_directory: /root/project/
|
2019-05-04 12:39:59 +00:00
|
|
|
command: |
|
2019-05-04 12:51:31 +00:00
|
|
|
set +o pipefail
|
2019-05-04 12:39:59 +00:00
|
|
|
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"
|
2019-05-04 12:43:13 +00:00
|
|
|
working_directory: /root/project/
|
2019-05-04 12:39:59 +00:00
|
|
|
command: |
|
2019-05-04 12:57:27 +00:00
|
|
|
for TARGET in `find public/ -type f | egrep "\.(css|js|png|jpg|JPG|PNG|CSS|JS)$"`
|
2019-05-04 12:39:59 +00:00
|
|
|
do
|
|
|
|
gzip -c ${TARGET} > ${TARGET}.gz
|
|
|
|
done
|
2019-05-04 13:13:59 +00:00
|
|
|
|
|
|
|
- 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:
|
2019-05-04 14:01:41 +00:00
|
|
|
name: Deploy (Not Master)
|
2019-05-04 13:13:59 +00:00
|
|
|
command: |
|
2019-05-04 14:01:41 +00:00
|
|
|
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
|