Skip to content

Instantly share code, notes, and snippets.

@shivanshs9
Created May 29, 2024 14:38
Show Gist options
  • Save shivanshs9/ca1a6f549dbe542ef1b79424d4c56390 to your computer and use it in GitHub Desktop.
Save shivanshs9/ca1a6f549dbe542ef1b79424d4c56390 to your computer and use it in GitHub Desktop.
Adds git commit author + message to deployment notification with this ArgoCD patch
---
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
template.app-deployed: |
email:
subject: New version of an application {{.app.metadata.name}} is up and running.
message: |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests.
slack:
attachments: |
[{
"title": "{{ .app.metadata.name}}",
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"color": "#18be52",
"fields": [
{
"title": "Sync Status",
"value": "{{.app.status.sync.status}}",
"short": true
},
{
"title": "Repository",
"value": "{{.app.spec.source.repoURL}}",
"short": true
},
{
"title": "Revision",
"value": "{{.app.status.sync.revision}}",
"short": true
},
{{- $commitMeta := (call .repo.GetCommitMetadata .app.status.sync.revision) }}
{
"title": "Author",
"value": "{{ ($commitMeta).Author }}",
"short": true
},
{
"title": "Message",
"value": "{{ (call .strings.ReplaceAll ($commitMeta).Message "\n" "\\n") }}",
"short": true
}
{{range $index, $c := .app.status.conditions}}
{{if not $index}},{{end}}
{{if $index}},{{end}}
{
"title": "{{$c.type}}",
"value": "{{$c.message}}",
"short": true
}
{{end}}
]
}]
groupingKey: ""
notifyBroadcast: false
teams:
facts: |
[{
"name": "Sync Status",
"value": "{{.app.status.sync.status}}"
},
{
"name": "Repository",
"value": "{{.app.spec.source.repoURL}}"
},
{
"name": "Revision",
"value": "{{.app.status.sync.revision}}"
}
{{range $index, $c := .app.status.conditions}}
{{if not $index}},{{end}}
{{if $index}},{{end}}
{
"name": "{{$c.type}}",
"value": "{{$c.message}}"
}
{{end}}
]
potentialAction: |-
[{
"@type":"OpenUri",
"name":"Operation Application",
"targets":[{
"os":"default",
"uri":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}"
}]
},
{
"@type":"OpenUri",
"name":"Open Repository",
"targets":[{
"os":"default",
"uri":"{{.app.spec.source.repoURL | call .repo.RepoURLToHTTPS}}"
}]
}]
themeColor: "#000080"
title: New version of an application {{.app.metadata.name}} is up and running.
@shivanshs9
Copy link
Author

Multi-line message handled with:
argoproj/argo-cd#9069 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment