Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.76 KiB
Newer Older
Ben Gamari's avatar
Ben Gamari committed
variables:
  LANG: en_US.UTF-8
  # DEPLOY_KEY provided as protected variable

stages:
  - build
  - 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
    - |
      echo "==============================="
      echo "Link Check:"
      echo "==============================="
      nix run -f . -c check.sh
Ben Gamari's avatar
Ben Gamari committed
    - 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

Ben Gamari's avatar
Ben Gamari committed
pages:
Ben Gamari's avatar
Ben Gamari committed
  stage: deploy
  dependencies:
    - build
  tags:
    - x86_64-linux
  only:
Ben Gamari's avatar
Ben Gamari committed
    - master
  script:
    - mkdir -p .public
Ben Gamari's avatar
Ben Gamari committed
    - cp -R _site/* .public
Ben Gamari's avatar
Ben Gamari committed
    - 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
  script:
    - echo "Deploying to haskell.org"
Ben Gamari's avatar
Ben Gamari committed
    - mkdir -p $HOME/.ssh
Ben Gamari's avatar
Ben Gamari committed
    - echo "$DEPLOY_KEY" > key
Ben Gamari's avatar
Ben Gamari committed
    - echo "webhost.haskell.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH2qKrYfhGC/7W/yLGjIkUPozDU+bJSNDFSrilUwyu8H5hbfSnlsBd/HvXvNc3TquDJ1T91J65AjGq+J+2F28Nw=" > $HOME/.ssh/known_hosts
    - chown -R 0600 $HOME/.ssh key
    - 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
  after_script:
Ben Gamari's avatar
Ben Gamari committed
    - rm -f key