.gitlab-ci.yml 1.84 KB
Newer Older
Ben Gamari's avatar
Ben Gamari committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
variables:
  LANG: en_US.UTF-8
  # DEPLOY_KEY provided as protected variable

stages:
  - build
  - check
  - deploy

image: nixos/nix

cache:
  policy: pull
  paths:
    - store.nar

before_script:
  - |
    if [ -f store.nar ]; then
      echo "Extracting cached Nix store..."
      nix-store --import -vv < store.nar || echo "invalid cache"
    else
      echo "No cache found"
    fi

build:
  stage: build
  tags:
    - x86_64-linux
  script:
    - nix build -f . --no-link
    - nix run -f . -c ghc-homepage build
    - nix-store --export $(nix-store -qR --include-outputs $(nix-instantiate --quiet .)) > store.nar
  cache:
    policy: pull-push
    paths:
      - store.nar
  artifacts:
    expire_in: 1 year
    paths:
      - _site

check-links:
  stage: check
Ben Gamari's avatar
Ben Gamari committed
45
  #allow_failure: true
Ben Gamari's avatar
Ben Gamari committed
46 47 48 49 50
  tags:
    - x86_64-linux
  script:
    - nix build -f . --no-link
    - nix run -f . -c ghc-homepage preview &
Ben Gamari's avatar
Ben Gamari committed
51
    - sleep 5
Ben Gamari's avatar
Ben Gamari committed
52 53 54
    - nix run -f . -c check.sh
    - kill %1

Ben Gamari's avatar
Ben Gamari committed
55
pages:
Ben Gamari's avatar
Ben Gamari committed
56 57 58 59 60 61
  stage: deploy
  dependencies:
    - build
  tags:
    - x86_64-linux
  only:
Ben Gamari's avatar
Ben Gamari committed
62 63 64
    - master
  script:
    - mkdir -p .public
Ben Gamari's avatar
Ben Gamari committed
65
    - cp -R _site/* .public
Ben Gamari's avatar
Ben Gamari committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    - mv .public public
  artifacts:
    paths:
      - public

deploy-webhost:
  stage: deploy
  dependencies:
    - build
  tags:
    - x86_64-linux
  only:
    - master
  environment:
    name: haskell.org
    url: https://haskell.org/ghc
Ben Gamari's avatar
Ben Gamari committed
82 83
  script:
    - echo "Deploying to haskell.org"
Ben Gamari's avatar
Ben Gamari committed
84
    - mkdir -p $HOME/.ssh
Ben Gamari's avatar
Ben Gamari committed
85
    - echo "$DEPLOY_KEY" > key
Ben Gamari's avatar
Ben Gamari committed
86 87
    - echo "webhost.haskell.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH2qKrYfhGC/7W/yLGjIkUPozDU+bJSNDFSrilUwyu8H5hbfSnlsBd/HvXvNc3TquDJ1T91J65AjGq+J+2F28Nw=" > $HOME/.ssh/known_hosts
    - chown -R 0600 $HOME/.ssh key
Ben Gamari's avatar
Ben Gamari committed
88
    - nix run -f . -c rclone sync _site --sftp-key-file=./key --sftp-user=ghc-site --sftp-host=webhost.haskell.org :sftp:/ghc
Ben Gamari's avatar
Ben Gamari committed
89
  after_script:
Ben Gamari's avatar
Ben Gamari committed
90
    - rm -f key