Skip to content

Commit

Permalink
Allow deploy action flag to be configured at the train level
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Oct 4, 2024
1 parent 0ccb6af commit dc61c1d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/bitbucket_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def workflows

def workflow_retriable? = false

def trigger_workflow_run!(ci_cd_channel, _branch_name, inputs, commit_hash = nil)
def trigger_workflow_run!(ci_cd_channel, _branch_name, inputs, commit_hash = nil, _deploy_action_enabled = false)
with_api_retries do
res = installation.trigger_pipeline!(code_repository_name, ci_cd_channel, inputs, commit_hash, WORKFLOW_RUN_TRANSFORMATIONS)
res.merge(ci_link: "https://bitbucket.org/#{code_repository_name}/pipelines/results/#{res[:number]}")
Expand Down
2 changes: 1 addition & 1 deletion app/models/bitrise_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def workflows
installation.list_workflows(project, WORKFLOWS_TRANSFORMATIONS)
end

def trigger_workflow_run!(ci_cd_channel, branch_name, inputs, commit_hash = nil)
def trigger_workflow_run!(ci_cd_channel, branch_name, inputs, commit_hash = nil, _deploy_action_enabled = false)
installation.run_workflow!(project, ci_cd_channel, branch_name, inputs, commit_hash, WORKFLOW_RUN_TRANSFORMATIONS)
end

Expand Down
3 changes: 1 addition & 2 deletions app/models/github_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ def workflows
installation.list_workflows(code_repository_name, WORKFLOWS_TRANSFORMATIONS)
end

def trigger_workflow_run!(ci_cd_channel, branch_name, inputs, commit_hash = nil)
deploy_action_enabled = organization.deploy_action_enabled? || app.deploy_action_enabled?
def trigger_workflow_run!(ci_cd_channel, branch_name, inputs, commit_hash = nil, deploy_action_enabled = false)
installation.run_workflow!(code_repository_name, ci_cd_channel, branch_name, inputs, commit_hash, deploy_action_enabled)
end

Expand Down
4 changes: 3 additions & 1 deletion app/models/step_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ def update_ci_metadata!(workflow_run)
def trigger_workflow_run(retrigger: false)
update_build_number! unless retrigger

deploy_action_enabled = organization.deploy_action_enabled? || app.deploy_action_enabled? || train.deploy_action_enabled?

ci_cd_provider
.trigger_workflow_run!(workflow_id, release_branch, workflow_inputs, commit_hash)
.trigger_workflow_run!(workflow_id, release_branch, workflow_inputs, commit_hash, deploy_action_enabled)
.then { |wr| update_ci_metadata!(wr) }
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def product_v2?
Flipper.enabled?(:product_v2, self)
end

def deploy_action_enabled?
Flipper.enabled?(:deploy_action_enabled, self)
end

def version_ahead?(release)
version_current.to_semverish >= release.release_version.to_semverish
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/workflow_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ def notification_params
private

def trigger_external_run!
deploy_action_enabled = organization.deploy_action_enabled? || app.deploy_action_enabled? || train.deploy_action_enabled?

ci_cd_provider
.trigger_workflow_run!(conf.id, release_branch, workflow_inputs, commit_hash)
.trigger_workflow_run!(conf.id, release_branch, workflow_inputs, commit_hash, deploy_action_enabled)
.then { |wr| update_external_metadata!(wr) }
end

Expand Down

0 comments on commit dc61c1d

Please sign in to comment.