Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
version: 2
jobs:
build:
# Ref: https://mmhaskell.com/blog/2018/4/25/dockerizing-our-haskell-app
docker:
- image: haskell:8.6.3
steps:
- run: apt update
- run: apt install -y zip jq curl
- run: stack upgrade
- run: "echo 'tcp 6 TCP' > /etc/protocols"
- run: "stack config --system-ghc set system-ghc --global true"
- checkout
- restore_cache:
keys:
- 'dependencies-{{ checksum "stack.yaml" }}-{{ checksum "haskell-jp-blog.cabal" }}'
- 'dependencies-'
# 下記のパッケージはビルド時にメモリが不足するため、一旦 -j1 でビルドしておく
# Ref: https://haskell.e-bigmoon.com/posts/2017/12-31-travis-out-of-memory.html
- run: stack build --compiler=ghc-8.6.3 --no-terminal -j1 Cabal wai-logger
- run: stack build --compiler=ghc-8.6.3 --no-terminal --only-dependencies
- save_cache:
key: 'dependencies-{{ checksum "stack.yaml" }}-{{ checksum "haskell-jp-blog.cabal" }}'
paths:
- ~/.stack/
- .stack-work/
- restore_cache:
keys:
- 'executable-{{ checksum "src/site.hs" }}'
- 'executable-'
- run: stack --compiler=ghc-8.6.3 --local-bin-path='.' --no-terminal install --pedantic
- save_cache:
key: 'executable-{{ checksum "src/site.hs" }}'
paths:
- ./site
- run: ./site build
- store_artifacts: { path: ./generated-site/ }
- run: |
if [ "$CIRCLE_BRANCH" != master ] ; then
printenv |
grep -E '^CIRCLE_|^HOME' | # Circle CIの環境変数を抽出して、preview botのサーバーにJSONとして渡す https://circleci.com/docs/2.0/env-vars/
jq -c -s -R 'split("\n")
| map (split("=")
| select(.[0] != null)
| {(.[0]): .[1:] | join("=")})
| add' |
curl -H 'Content-Type:application/json' -d @- \
http://haskell-jp-blog-artifact.hask.moe/
fi
- persist_to_workspace:
root: .
paths:
- ./generated-site
deploy:
docker:
- image: haskell:8.6.3
steps:
- checkout:
path: ~/project
- add-ssh-keys:
fingerprints:
- "ce:26:f9:6a:ac:98:43:91:5c:c8:77:ef:11:13:d3:fc"
- run: apt update
- run: apt install -y make ssh-client
- attach_workspace:
at: .
- run: |
git config --global user.email "ci@haskell.jp"
git config --global user.name "Circle CI User"
ssh-keyscan github.com >> ~/.ssh/known_hosts
STACK_LOCAL_INSTALL_PATH=dummy make -W site -W dummy/site -e deploy
workflows:
version: 2
build_and_deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only:
- master