Sha256: 3d4d64216d8c091c890cf4bda3605ec599e8c6c89fa203d6184436ce41aaada7

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 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, canonical_sha, state, options
      else
        statuses.map do |status|
          options = {
            context: status["context"] || "concourse",
            target_url: target_url,
            description: status["description"] || ""
          }
          github.create_status repo, canonical_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}@#{canonical_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

4 entries across 4 versions & 1 rubygems

Version Path
concourse-github-status-0.6.6 lib/github-status/out.rb
concourse-github-status-0.6.4 lib/github-status/out.rb
concourse-github-status-0.6.3 lib/github-status/out.rb
concourse-github-status-0.6.2 lib/github-status/out.rb