cache:
  untracked: true
  paths:
    - node_modules/

stages:
  - build
  - deploy

build:
  stage: build
  image: golang:1-alpine
  artifacts:
    paths:
      - dist
  script:
    - apk add --no-cache imagemagick pkgconfig imagemagick-dev gcc libc-dev
    - rm -rf previews && mkdir -p previews
    - rm -rf dist && mkdir -p dist
    - go run main.go
    - mv index.html dist/
    - mv previews/ dist/
    - mv talks/ dist/

deploy:
  stage: deploy
  image: node:16-alpine
  script:
    - npm i -g netlify-cli
    - netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
