diff --git a/README.md b/README.md index 61c65ec..4d0fc2d 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,8 @@ Set the status message for `concourse-ci` context on specified pull request. * `label`: *Optional.* A label to add to the pull request. +* `delete_label`: *Optional.* A label to remove from the pull request. + ## Example pipeline Please see this repo's [pipeline](https://github.com/jtarchie/pullrequest-resource/blob/master/.concourse.yml) for a perfect example. diff --git a/assets/lib/commands/out.rb b/assets/lib/commands/out.rb index 547a581..c88b043 100755 --- a/assets/lib/commands/out.rb +++ b/assets/lib/commands/out.rb @@ -71,6 +71,17 @@ def output metadata << { 'name' => 'label', 'value' => params.label } end + if params.delete_label + label_exists = Octokit.labels_for_issue(input.source.repo, id).select do |hash| + hash.to_hash[:name] == params.delete_label + end + + if label_exists.any? + Octokit.remove_label(input.source.repo, id, params.delete_label) + end + metadata << { 'name' => 'delete_label', 'value' => params.delete_label } + end + if params.merge.method commit_msg = if params.merge.commit_msg commit_path = File.join(destination, params.merge.commit_msg)