Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (83 sloc) 2.79 KB
version: 2
jobs:
build:
# Ref: https://mmhaskell.com/blog/2018/4/25/dockerizing-our-haskell-app
docker:
- image: haskell:8.2.1
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.2.1 --no-terminal -j1 Cabal wai-logger
- run: stack build --compiler=ghc-8.2.1 --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.2.1 --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 @- \
https://haskell-jp-blog-artifact.herokuapp.com/
fi
- persist_to_workspace:
root: .
paths:
- ./generated-site
deploy:
docker:
- image: haskell:8.2.1
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.