stages:
  - vetting
  - test
  - build
  - deploy

Lint:
  image: 
    - golang
  stage: vetting
  script:
    - go get golang.org/x/lint/golint
    - golint -set_exit_status ./...
  allow_failure: true

Vet:
  image: 
    - golang
  stage: vetting
  script:
    - go vet ./...

Test:
  stage: test
  image:
    - golang
  script:
    - go test mytelegram251bot

Build:
  stage: build
  image:
    - golang
  before_script:
    - go version
    - echo $CI_BUILD_REF
    - echo $CI_PROJECT_DIR
  script:
    - mkdir -p .cache
    - export GOPATH="$CI_PROJECT_DIR/.cache"
    - make
  artifacts:
    paths:
      - "bin/*"
    name: "mytelegram251bot-$CI_COMMIT_REF_NAME"

Staging:
  stage: deploy
  image:
    - ruby
  script:
    - gem install dpl
    - dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
  environment:
    name: Staging
  only:
    - master

Production:
  stage: deploy
  image:
    - ruby
  script:
    - gem install dpl
    - dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
  environment:
    name: Production
  only:
    - master
  when: manual
