Skip to content

Commit

Permalink
Merge pull request #19 from simplybusiness/pr-target-event
Browse files Browse the repository at this point in the history
change pr target event on all places.
  • Loading branch information
Punit Jain authored Sep 13, 2021
2 parents 6651b0b + a4101cb commit 95f4f7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion lib/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

begin
config = GithubApiConfig.new
puts "Event: #{config.event_name} called"
case config.event_name
when 'pull_request', 'pull_request_target'
if config.event_payload['action'] == 'opened' || config.event_payload['action'] == 'synchronize'
Expand Down
5 changes: 3 additions & 2 deletions lib/functionality/base_deploy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

# Checks the deploy checks present
class BaseDeployCheck
def self.base_check(config, event, sha) # rubocop:disable Metrics/AbcSize
result = if !config.event_branch.include?('master') && SimplyIssue.get_all_issues(
def self.base_check(config, event, sha)
puts "config event branch #{config.event_branch}"
result = if SimplyIssue.get_all_issues(
config, event,
'block deploys'
).length.positive?
Expand Down
6 changes: 3 additions & 3 deletions lib/functionality/simply_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

# Fetch the labels on PR and issue
class SimplyIssue
def self.get_label_tags(config)
if config.event_name == 'pull_request'
puts config.event_payload['number']
def self.get_label_tags(config) # rubocop:disable Metrics/AbcSize
if ['pull_request', 'pull_request_target'].include?(config.event_name)
puts "Pull request #{config.event_payload['number']}"
issue = config.client.pull_request(config.app_repo, config.event_payload['number'])
else
issue = config.client.issue(config.app_repo, config.event_payload['issue']['number'])
Expand Down
14 changes: 0 additions & 14 deletions specs/base_deploy_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@

let(:config) { GithubApiConfig.new }

context 'when branch is master' do
it 'returns a success for the deploy check' do
ENV['GITHUB_EVENT_PATH'] = Pathname.new(SPEC_FIXTURES_PATH).join('push_payload.json').to_s
ENV['GITHUB_REF'] = 'ref/master'
ENV['GITHUB_EVENT_NAME'] = 'push'
sha = '63f739d5586b2c6b718045893789d620e0d0aee9'

VCR.use_cassette('status update success') do
response = PrDeployCheck.base_check(config, 'issues', sha)
expect(response['state']).to eq('success')
end
end
end

context 'when there are no blocked deploy issues' do
it 'returns a success for the deploy check' do
ENV['GITHUB_EVENT_PATH'] = Pathname.new(SPEC_FIXTURES_PATH).join('open_pr_payload.json').to_s
Expand Down

0 comments on commit 95f4f7e

Please sign in to comment.