image: golang:1.6

stages:
- build
- mirror

before_script:
- source ci/prepare

.build: &build-template
  stage: build
  script:
  - source ci/build
  - source ci/deploy "$CI_BUILD_NAME"

Development:
  <<: *build-template
  only:
  - branches
  except:
  - master@gitlab-org/gitlab-ci-multi-runner
  - tags@gitlab-org/gitlab-ci-multi-runner

Bleeding Edge:
  <<: *build-template
  only:
  - master@gitlab-org/gitlab-ci-multi-runner

Stable Release:
  <<: *build-template
  variables:
    RELEASE: "true"
  only:
  - tags@gitlab-org/gitlab-ci-multi-runner

Mirror:
  stage: mirror
  script:
  - mkdir -p ~/.ssh
  - echo "$GITHUB_SSH_KEY" > ~/.ssh/id_rsa
  - ssh-keyscan -H github.com > ~/.ssh/known_hosts
  - chmod -R 0600 ~/.ssh/
  - git remote add github git@github.com:ayufan/gitlab-ci-multi-runner.git
  - git fetch github
  - git push github "$CI_BUILD_REF_NAME" -f
  only:
  - master@gitlab-org/gitlab-ci-multi-runner
  - tags@gitlab-org/gitlab-ci-multi-runner

image: golang:1.6

stages:
- build
- mirror

before_script:
- source ci/prepare

.build: &build-template
  stage: build
  script:
  - source ci/build
  - source ci/deploy "$CI_BUILD_NAME"

Development:
  <<: *build-template
  only:
  - branches
  except:
  - master@gitlab-org/gitlab-ci-multi-runner
  - tags@gitlab-org/gitlab-ci-multi-runner

Bleeding Edge:
  <<: *build-template
  only:
  - master@gitlab-org/gitlab-ci-multi-runner
  environment: bleeding_edge

Stable Release:
  <<: *build-template
  variables:
    RELEASE: "true"
  only:
  - tags@gitlab-org/gitlab-ci-multi-runner
  environment: stable_release

Mirror:
  stage: mirror
  script:
  - mkdir -p ~/.ssh
  - echo "$GITHUB_SSH_KEY" > ~/.ssh/id_rsa
  - ssh-keyscan -H github.com > ~/.ssh/known_hosts
  - chmod -R 0600 ~/.ssh/
  - git remote add github git@github.com:ayufan/gitlab-ci-multi-runner.git
  - git fetch github
  - git push github "$CI_BUILD_REF_NAME" -f
  only:
  - master@gitlab-org/gitlab-ci-multi-runner
  - tags@gitlab-org/gitlab-ci-multi-runner

Add environments for Bleeding Edge and Stable Release
Add environments for Bleeding Edge and Stable Release
