Skip to content

Commit

Permalink
- Added deployment branch to GitHUb webhook filters.
Browse files Browse the repository at this point in the history
- Preping for EventPattern in EventsRules
  • Loading branch information
gitwater committed Feb 12, 2022
1 parent 3f3af4f commit fbd453d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
7 changes: 6 additions & 1 deletion src/paco/application/reseng_deploymentpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,15 @@ def stack_hook_codebuild_github_access_token(self, hook, config):

if config.trigger_on_push == True:
project_name = hook['stack'].template.get_project_name()
deployment_branch_name = config.deployment_branch_name.replace('/', '\/')
filter_groups = [[
{
'type': 'EVENT',
'pattern': 'PUSH'
'pattern': 'PUSH',
},
{
'type': 'HEAD_REF',
'pattern': f'^refs/heads/{deployment_branch_name}$'
}
]]

Expand Down
36 changes: 23 additions & 13 deletions src/paco/cftemplates/eventsrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def __init__(
return

# Parameters
schedule_expression_param = self.create_cfn_parameter(
param_type = 'String',
name = 'ScheduleExpression',
description = 'ScheduleExpression for the Event Rule.',
value = eventsrule.schedule_expression,
)
schedule_expression_param = None
if eventsrule.schedule_expression:
schedule_expression_param = self.create_cfn_parameter(
param_type = 'String',
name = 'ScheduleExpression',
description = 'ScheduleExpression for the Event Rule.',
value = eventsrule.schedule_expression,
)
description_param = self.create_cfn_parameter(
param_type = 'String',
name = 'EventDescription',
Expand Down Expand Up @@ -157,14 +159,22 @@ def __init__(
enabled_state = 'ENABLED'
else:
enabled_state = 'DISABLED'
event_rule_resource = troposphere.events.Rule(


events_rule_dict = {
'Name': name,
'Description': troposphere.Ref(description_param),
'RoleArn': troposphere.GetAtt(target_invocation_role_resource, 'Arn'),
'Targets': targets,
'State': enabled_state
}

if schedule_expression_param != None:
events_rule_dict['ScheduleExpression'] = troposphere.Ref(schedule_expression_param)

event_rule_resource = troposphere.events.Rule.from_dict(
'EventRule',
Name=name,
Description=troposphere.Ref(description_param),
ScheduleExpression=troposphere.Ref(schedule_expression_param),
RoleArn=troposphere.GetAtt(target_invocation_role_resource, 'Arn'),
Targets=targets,
State=enabled_state
evens_rule_dict
)
event_rule_resource.DependsOn = target_invocation_role_resource
self.template.add_resource(event_rule_resource)
Expand Down

0 comments on commit fbd453d

Please sign in to comment.