1
1
mirror of https://github.com/nmattia/niv.git synced 2024-12-01 15:56:03 +03:00
niv/.circleci/config.yml

81 lines
2.1 KiB
YAML
Raw Normal View History

2019-01-31 22:47:23 +03:00
version: 2
jobs:
build-nix:
2019-04-04 13:46:41 +03:00
2019-01-31 22:47:23 +03:00
machine:
enabled: true
2019-04-04 13:46:41 +03:00
2019-01-31 22:47:23 +03:00
steps:
2019-04-04 13:46:41 +03:00
2019-01-31 22:47:23 +03:00
- run:
2019-04-04 13:46:41 +03:00
name: Prepare nix directories
2019-01-31 22:47:23 +03:00
command: |
sudo mkdir -p /nix
sudo chown circleci /nix
2019-04-04 13:46:41 +03:00
2019-02-05 17:21:51 +03:00
sudo mkdir -p /etc/nix
2019-02-05 16:19:17 +03:00
# 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
2019-04-05 12:43:57 +03:00
# 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
2019-01-31 22:47:23 +03:00
- run:
2019-04-04 13:46:41 +03:00
name: Install Nix
2019-01-31 22:47:23 +03:00
command: |
2019-06-16 11:25:06 +03:00
until bash <(curl https://nixos.org/nix/install)
do
echo "Nix install failed, retrying"
2019-06-16 11:53:52 +03:00
sudo rm -rf /nix
sudo mkdir -p /nix
sudo chown circleci /nix
2019-06-16 11:25:06 +03:00
done
2019-04-04 13:46:41 +03:00
echo '. /home/circleci/.nix-profile/etc/profile.d/nix.sh' >> $BASH_ENV
2019-01-31 22:47:23 +03:00
2019-04-04 13:46:41 +03:00
- checkout
2019-02-05 17:04:15 +03:00
2019-01-31 22:47:23 +03:00
- run:
name: Nix build
2019-02-01 17:51:40 +03:00
command: ./script/test
2019-01-31 22:47:23 +03:00
2019-04-14 15:49:13 +03:00
- 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
2019-01-31 22:47:23 +03:00
workflows:
version: 2
build:
jobs:
2019-04-14 15:49:13 +03:00
- build-nix:
context: niv-netlify