1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-25 20:45:21 +03:00
niv/.circleci/config.yml
2019-04-14 21:11:18 +02:00

75 lines
1.9 KiB
YAML

version: 2
jobs:
build-nix:
machine:
enabled: true
steps:
- run:
name: Prepare nix directories
command: |
sudo mkdir -p /nix
sudo chown circleci /nix
sudo mkdir -p /etc/nix
# Enable sandbox
echo "sandbox = true" | sudo tee -a /etc/nix/nix.conf
# Keep derivations and their outputs for better caching
echo "keep-outputs = true" | sudo tee -a /etc/nix/nix.conf
echo "keep-derivations = true" | sudo tee -a /etc/nix/nix.conf
# Set a new TMP because /run/user is (1) pretty small and (2)
# mounted with noexec
new_tmp=$HOME/tmp
mkdir -p $new_tmp
echo "export TMPDIR=$new_tmp" >> $BASH_ENV
- run:
name: Install Nix
command: |
bash <(curl https://nixos.org/nix/install)
echo '. /home/circleci/.nix-profile/etc/profile.d/nix.sh' >> $BASH_ENV
- checkout
- run:
name: Nix build
command: ./script/test
- run:
name: "Update Node.js and npm (master only)"
command: |
if [ "$CIRCLE_BRANCH" == "master" ]; then
nix-env -f ./nix -iA nodejs-10_x
fi
- run:
name: "Install netlify-cli (master only)"
command: |
if [ "$CIRCLE_BRANCH" == "master" ]; then
npm install netlify-cli
fi
- run:
name: "Netlify deploy (master only)"
command: |
if [ "$CIRCLE_BRANCH" == "master" ]; then
echo "Deploying to production"
./node_modules/netlify-cli/bin/run deploy \
--dir=./site \
--message="$CIRCLE_SHA1" --prod
else
echo "Not deploying"
fi
workflows:
version: 2
build:
jobs:
- build-nix:
context: niv-netlify