stages:
  - build
  - test
  - github
  - cleanup

push to github:
  image: wurbanski/alpine-git
  stage: github
  tags:
    - docker-runner
  script:
    - if [ ! -n "$(grep "^github.com " ~/.ssh/known_hosts)" ]; then ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null; fi
    - eval $(ssh-agent -s)
    - echo "$GITHUB_SSH_KEY" > /tmp/ssh_key && chmod 600 /tmp/ssh_key
    - ssh-add /tmp/ssh_key
    - git push $GITHUB_REPO_URL HEAD:master 
    - ssh-agent -k || { ssh-agent -k ; exit 1; }
  allow_failure: True
  only:
    - master
stages:
  - build
  - test
  - github

.job_template: &job
  tags:
    - docker-runner

build alpine:
  <<: *job
  image: golang:1.8-alpine
  stage: build
  script:
    - go build

build linux:
  <<: *job
  image: golang:1.8
  stage: build
  script:
    - go build

push to github:
  <<: *job
  image: wurbanski/alpine-git
  stage: github
  script:
    - if [ ! -n "$(grep "^github.com " ~/.ssh/known_hosts)" ]; then ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null; fi
    - eval $(ssh-agent -s)
    - echo "$GITHUB_SSH_KEY" > /tmp/ssh_key && chmod 600 /tmp/ssh_key
    - ssh-add /tmp/ssh_key
    - git push $GITHUB_REPO_URL HEAD:master 
    - ssh-agent -k || { ssh-agent -k ; exit 1; }
  allow_failure: True
  only:
    - master
Add build jobs to CI
Add build jobs to CI
