Sha256: 0bf4dc7c3bd0c338520daeafe2f8328963bb00b7c9bae618e1ea3723c78374e8

Contents?: true

Size: 1.12 KB

Versions: 53

Compression:

Stored size: 1.12 KB

Contents

# https://semaphoreci.com/docs/available-environment-variables.html
require "danger/request_sources/github/github"

module Danger
  # ### CI Setup
  #
  # For Semaphore you will want to go to the settings page of the project. Inside "Build Settings"
  # you should add `bundle exec danger` to the Setup thread. Note that Semaphore only provides
  # the build environment variables necessary for Danger on PRs across forks.
  #
  # ### Token Setup
  #
  # You can add your `DANGER_GITHUB_API_TOKEN` inside the "Environment Variables" section in the settings.
  #
  class Semaphore < CI
    def self.validates_as_ci?(env)
      env.key? "SEMAPHORE"
    end

    def self.validates_as_pr?(env)
      ["SEMAPHORE_REPO_SLUG", "PULL_REQUEST_NUMBER"].all? { |x| env[x] && !env[x].empty? }
    end

    def supported_request_sources
      @supported_request_sources ||= [Danger::RequestSources::GitHub]
    end

    def initialize(env)
      self.repo_slug = env["SEMAPHORE_REPO_SLUG"]
      self.pull_request_id = env["PULL_REQUEST_NUMBER"]
      self.repo_url = GitRepo.new.origins # Semaphore doesn't provide a repo url env variable :/
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
danger-5.5.11 lib/danger/ci_source/semaphore.rb
danger-5.5.10 lib/danger/ci_source/semaphore.rb
danger-5.5.9 lib/danger/ci_source/semaphore.rb
danger-5.5.8 lib/danger/ci_source/semaphore.rb
danger-5.5.7 lib/danger/ci_source/semaphore.rb
danger-5.5.6 lib/danger/ci_source/semaphore.rb
danger-5.5.5 lib/danger/ci_source/semaphore.rb
danger-5.5.4 lib/danger/ci_source/semaphore.rb
danger-5.5.3 lib/danger/ci_source/semaphore.rb
danger-5.5.2 lib/danger/ci_source/semaphore.rb
danger-5.5.1 lib/danger/ci_source/semaphore.rb
danger-5.5.0 lib/danger/ci_source/semaphore.rb
danger-5.4.3 lib/danger/ci_source/semaphore.rb