Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidd6 committed Nov 30, 2019
1 parent 2c3aee4 commit 8724951
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Delete no branches
- name: Test
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 10 additions & 10 deletions main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
require 'octokit'

repo = ENV['GITHUB_REPOSITORY']

token = ENV['INPUT_GITHUB_TOKEN']
branches = ENV['INPUT_BRANCHES']
numbers = ENV['INPUT_NUMBERS']
prefix = ENV['INPUT_PREFIX']
suffix = ENV['INPUT_SUFFIX']

client = Octokit::Client.new(access_token: token)

numbers = numbers&.split(',') || []
branches = branches&.split(',') || []

numbers.each do |number|
begin
pull = client.pull_request(repo, number)
branches << pull['head']['ref']
rescue StandardError
puts "==> Not a PR: ##{number}"
rescue StandardError => e
puts "==> Error: #{e.message}"
end
end

branches = branches.map { |branch| prefix + branch } if prefix
branches = branches.map { |branch| branch + suffix } if suffix

branches.each do |branch|
if client.delete_branch(repo, branch)
puts "==> Deleted: #{branch}"
else
puts "==> Failed to delete: #{branch}"
exit 1
begin
if client.delete_branch(repo, branch)
puts "==> Deleted: #{branch}"
else
puts "==> Failed to delete: #{branch}"
end
rescue StandardError => e
puts "==> Error: #{e.message}"
end
end

0 comments on commit 8724951

Please sign in to comment.