workspace:
  base: /go
  path: src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator

clone:
  git:
    image: plugins/git:1
    depth: 50
    tags: true

pipeline:
  deps:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    commands:
      - go get -u github.com/golang/dep/cmd/dep
      - dep ensure
      - go get -u github.com/gobuffalo/packr/...
      - packr -z
  test:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    commands:
      - make test build
  coverage:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    secrets: [ coveralls_token ]
    commands:
      - make coverage
  static:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    commands:
      - make generate-release-file release
    when:
      event: [ push ]
      branch: [ master ]
  static:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    commands:
      - make generate-release-file release
    when:
      event: [ tag ]
  clean:
    image: golang:1.11.2
    pull: true
    environment:
      GOPATH: /go
    commands:
      - packr clean
  gitea:
    image: plugins/gitea-release:latest
    pull: true
    base_url: "https://git.jonasfranz.software"
    secrets: [ gitea_token ]
    title: .version
    note: .changelog.yml
    files:
      - releases/*
    checksum:
      - sha256
      - md5
    when:
      event: [ tag ]
  docker:
    image: plugins/docker:17.12
    secrets: [ docker_username, docker_password ]
    pull: true
    repo: ggmigrator/cli
    default_tags: true
    when:
      event: [ push, tag ]

  docker-web:
    image: plugins/docker:17.12
    secrets: [ docker_username, docker_password ]
    pull: true
    dockerfile: Dockerfile.web
    repo: ggmigrator/web
    default_tags: true
    when:
      event: [ push, tag ]
  s3:
    image: plugins/s3:1
    pull: true
    secrets: [ aws_access_key_id, aws_secret_access_key ]
    bucket: gitea-github-migrator
    path_style: true
    acl: public-read
    source: releases/*
    target: dist/master
    strip_prefix: releases/
    endpoint: https://storage.h.jonasfranz.software
    when:
      event: [ push ]
      branch: [ master ]
  s3:
    image: plugins/s3:1
    pull: true
    secrets: [ aws_access_key_id, aws_secret_access_key ]
    bucket: gitea-github-migrator
    path_style: true
    acl: public-read
    source: releases/*
    target: dist/${DRONE_TAG##v}
    strip_prefix: releases/
    endpoint: https://storage.h.jonasfranz.software
    when:
      event: [ tag ]

services:
  gitea:
    image: jonasfranz/gitea-service
    pull: true
