image: alpine:edge

before_script:
  - apk add lftp
  - apk add git
  - apk add go
  - apk add hugo

variables:
  GIT_SUBMODULE_STRATEGY: recursive

workflow:
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

pages:
  stage: build
  script:
  - hugo
  - ls -lisah .
  - ls -lisah ../../../tmp/hugo_cache
  - ls -lisah ../../../tmp/hugo_cache/modules
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-themes
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-themes/modules
  - ls -lisah ../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/
  - hugo
  artifacts:
    expire_in: 1 day
    paths:
    - public

upload:
  stage: deploy
  script:
    - echo $APSIS_LANDING_WWW
    - echo $FTP_USERNAME
    - echo $FTP_HOSTNAME
    - lftp --version
    - ls -lisah
    - ls -lisah public
    - lftp -c "open -u $FTP_USERNAME,$FTP_PASSWORD $FTP_HOSTNAME; mirror -Renv public/ $APSIS_LANDING_WWW"
