kind: pipeline
type: docker
name: default

steps:
- name: restore-cache-with-filesystem
  image: meltwater/drone-cache
  pull: true
  settings:
    backend: "filesystem"
    #debug: true
    restore: true
    cache_key: '{{ .Repo.Name }}_{{ arch }}_{{ os }}'
    archive_format: "tar"
    filesystem_cache_root: "/go"
    local_root: /
    mount:
      - pkg.mod
      - pkg.build
  volumes:
  - name: cache
    path: /go

- name: build
  image: golang
  environment:
    CGO_ENABLED: 0
    GOMODCACHE: '/drone/src/pkg.mod'
    GOCACHE: '/drone/src/pkg.build'  
  volumes:
  - name: shared
    path: /shared    
  commands:
  #- cp /shared/index.html ./www/
  #- go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
  #- sqlc generate
  - chmod +x .drone.sh
  - ./.drone.sh

- name: dell-sftp-deploy
  image: hypervtechnics/drone-sftp
  settings:
    host: deft.dell.com
    username:
      from_secret: DELLFTP_USER
    password:
      from_secret: DELLFTP_PASS
    port: 22
    source: ./build
    filter: mocksnow*
    clean: false
    target: /
    overwrite: true
    verbose: true

- name: rebuild-cache-with-filesystem
  image: meltwater/drone-cache
  pull: true
  #when:
  #  event:
  #  - tag  
  settings:
    backend: "filesystem"
    #debug: true
    rebuild: true
    cache_key: '{{ .Repo.Name }}_{{ arch }}_{{ os }}'
    archive_format: "tar"
    filesystem_cache_root: "/go"
    mount:
      - pkg.mod
      - pkg.build
  volumes:
  - name: cache
    path: /go    

volumes:
- name: shared
  temp: {}
- name: cache
  host:
    path: /var/lib/cache    