Skip to content
Snippets Groups Projects

Create & deploy golang applicaiton to Heroku using GitLab CI / CD

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Kiryuu Sakuya

    Test -> Build -> Push to test environment -> Manually push to production environment

    Edited
    .gitlab-ci.yml 1.09 KiB
    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
    makefile 210 B
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment