diff --git a/examples/workflows/new_github_stars.yml b/examples/workflows/new_github_stars.yml index 84ca9a3e8..4e9484ec6 100644 --- a/examples/workflows/new_github_stars.yml +++ b/examples/workflows/new_github_stars.yml @@ -1,7 +1,7 @@ # Alert when there are new GitHub Stars utilizing keepstate workflow: id: new-github-stars - description: Get new GitHub Stars + description: Notify Slack about new GitHub star for keephq/keep triggers: - type: interval value: 300 @@ -20,7 +20,7 @@ workflow: condition: - name: assert-condition type: assert - assert: "{{ steps.get-github-stars.results.new_stargazers_count }} == 0" # if there are more than 0 new stargazers, trigger the action + assert: "{{ steps.get-github-stars.results.new_stargazers_count }} > 0" # if there are more than 0 new stargazers, trigger the action provider: type: slack config: " {{ providers.slack-demo }} " diff --git a/keep/workflowmanager/workflowscheduler.py b/keep/workflowmanager/workflowscheduler.py index f6d7bb00f..31966cf9d 100644 --- a/keep/workflowmanager/workflowscheduler.py +++ b/keep/workflowmanager/workflowscheduler.py @@ -343,10 +343,6 @@ def _finish_workflow_execution( status: WorkflowStatus, error=None, ): - # get the previous workflow execution id - previous_execution = get_previous_execution_id( - tenant_id, workflow_id, workflow_execution_id - ) # mark the workflow execution as finished in the db finish_workflow_execution_db( tenant_id=tenant_id, @@ -355,10 +351,15 @@ def _finish_workflow_execution( status=status.value, error=error, ) + # get the previous workflow execution id + previous_execution = get_previous_execution_id( + tenant_id, workflow_id, workflow_execution_id + ) # if error, send an email - if ( - status == WorkflowStatus.ERROR - and previous_execution.status != WorkflowStatus.ERROR.value + if status == WorkflowStatus.ERROR and ( + previous_execution + is None # this means this is the first execution, for example + or previous_execution.status != WorkflowStatus.ERROR.value ): workflow = get_workflow_db(tenant_id=tenant_id, workflow_id=workflow_id) self.logger.info(