diff --git a/examples/workflows/new_github_stars.yml b/examples/workflows/new_github_stars.yml index 4e9484ec6..41f91e3d5 100644 --- a/examples/workflows/new_github_stars.yml +++ b/examples/workflows/new_github_stars.yml @@ -1,41 +1,42 @@ -# Alert when there are new GitHub Stars utilizing keepstate -workflow: - id: new-github-stars - description: Notify Slack about new GitHub star for keephq/keep - triggers: - - type: interval - value: 300 - steps: - - name: get-github-stars - provider: - type: github.stars - config: "{{ providers.github }}" - with: - repository: "keephq/keep" - previous_stars_count: - key: "{{ state.new-github-stars.-1.workflow_context.steps_context.get-github-stars.results.stars }}" - default: 0 - actions: - - name: trigger-slack - condition: - - name: assert-condition +id: new-github-stars +description: Notify Slack about new GitHub star for keephq/keep +triggers: + - type: manual + - type: interval + value: 300 +steps: + - name: get-github-stars + provider: + config: "{{ providers.github }}" + type: github.stars + with: + previous_stars_count: + default: 0 + key: "{{ last_workflow_results.get-github-stars.0.stars }}" + repository: keephq/keep +actions: + - condition: + - assert: "{{ steps.get-github-stars.results.new_stargazers_count }} > 0" + 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 - provider: - type: slack - config: " {{ providers.slack-demo }} " - with: - blocks: - - type: section - text: - type: plain_text - text: There are new keep.len({{ steps.get-github-stars.results.new_stargazers }}) stargazers for keephq/keep - emoji: true - - type: section - text: - type: plain_text - text: |- - {{#steps.get-github-stars.results.new_stargazers}} - - {{username}} at {{starred_at}} - {{/steps.get-github-stars.results.new_stargazers}} - emoji: true + name: trigger-slack + provider: + config: "{{ providers.slack-demo }}" + type: slack + with: + blocks: + - text: + emoji: true + text: There are new keep.len({{ steps.get-github-stars.results.new_stargazers}}) stargazers for keephq/keep + type: plain_text + type: section + - text: + emoji: true + text: "{{#steps.get-github-stars.results.new_stargazers}} + + - {{username}} at {{starred_at}} + + {{/steps.get-github-stars.results.new_stargazers}}" + type: plain_text + type: section + channel: "C06N0KXXXX" diff --git a/keep/api/bl/enrichments.py b/keep/api/bl/enrichments.py index e805ba5bc..43c98c205 100644 --- a/keep/api/bl/enrichments.py +++ b/keep/api/bl/enrichments.py @@ -7,10 +7,13 @@ from keep.api.models.db.mapping import MappingRule -def get_nested_attribute(obj, attr_path: str): +def get_nested_attribute(obj: AlertDto, attr_path: str): """ Recursively get a nested attribute """ + # Special case for source, since it's a list + if attr_path == "source" and obj.source is not None and len(obj.source) > 0: + return obj.source[0] attributes = attr_path.split(".") for attr in attributes: # @@ is used as a placeholder for . in cases where the attribute name has a .