Sha256: ce08dae8e7cf0dbc1fbfe948ccdc2dfeaee2d470927ab57351c275c4bf8657ce

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby

require 'concourse-fuselage'
require 'contracts'
require_relative 'core'
require_relative 'support/params'
require_relative 'support/git'
require_relative 'support/github'

module GitHubStatus
  class Out < Fuselage::Out
    include Core
    include Support::Params
    include Support::Git
    include Support::GitHub

    Contract None => Or[Sawyer::Resource, ArrayOf[Sawyer::Resource]]
    def update!
      if statuses.empty?
        github.create_status repo, sha, state, options
      else
        statuses.map do |status|
          options = {
            context: status["context"] || "concourse",
            target_url: target_url,
            description: status["description"] || ""
          }
          github.create_status repo, sha, status["state"], options
        end
      end
    rescue Octokit::Error => error
      STDERR.puts error.message
      abort
    end

    Contract None => HashOf[String, String]
    def version
      { 'context@sha' => "#{context}@#{sha}" }
    end

    Contract None => String
    def target_url
      @target_url ||= "#{atc_external_url}/builds/#{build_id}"
    end

    Contract None => HashOf[Symbol, String]
    def options
      @options ||= {
        context: context,
        target_url: target_url,
        description: description
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
concourse-github-status-0.5.11 lib/github-status/out.rb
concourse-github-status-0.5.10 lib/github-status/out.rb
concourse-github-status-0.5.9 lib/github-status/out.rb
concourse-github-status-0.5.8 lib/github-status/out.rb
concourse-github-status-0.5.7 lib/github-status/out.rb