Skip to content

Commit a683bd4

Browse files
committed
Fix: Update application name in argocd-test-app.yaml and enhance payload handling in ArgoCD deployment failure workflow
1 parent 90f91f6 commit a683bd4

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

.github/argocd/argocd-notifications-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,14 @@ data:
3737
"event_type": "argocd-sync-failed",
3838
"client_payload": {
3939
"app_name": "{{.app.metadata.name}}",
40-
"app_namespace": "{{.app.metadata.namespace}}",
41-
"sync_status": "{{.app.status.sync.status}}",
4240
"health_status": "{{.app.status.health.status}}",
43-
"operation_phase": "{{.app.status.operationState.phase}}",
41+
"sync_status": "{{.app.status.sync.status}}",
4442
"message": "{{.app.status.operationState.message}}",
4543
"revision": "{{.app.status.sync.revision}}",
4644
"repo_url": "{{.app.spec.source.repoURL}}",
47-
"target_revision": "{{.app.spec.source.targetRevision}}",
48-
"timestamp": "{{.app.status.operationState.finishedAt}}",
49-
"cluster": "{{.app.spec.destination.server}}",
50-
"cluster_name": "{{.app.spec.destination.name}}",
45+
"cluster": "{{if .app.metadata.labels.cluster-name}}{{.app.metadata.labels.cluster-name}}{{else}}{{.app.spec.destination.server}}{{end}}",
5146
"namespace": "{{.app.spec.destination.namespace}}",
47+
"timestamp": "{{.app.status.operationState.finishedAt}}",
5248
"resources": {{toJson .app.status.resources}}
5349
}
5450
}

.github/workflows/argocd-deployment-failure.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,29 @@ jobs:
1919
script: |
2020
const payload = context.payload.client_payload || {};
2121
const appName = payload.app_name || 'unknown';
22-
const clusterUrl = payload.cluster || 'unknown';
23-
const clusterName = payload.cluster_name || clusterUrl;
22+
const cluster = payload.cluster || 'unknown';
2423
const namespace = payload.namespace || 'default';
2524
const healthStatus = payload.health_status || 'unknown';
2625
const syncStatus = payload.sync_status || 'unknown';
2726
const message = payload.message || 'No error message available';
2827
const revision = payload.revision || 'unknown';
2928
const repoUrl = payload.repo_url || '';
30-
const targetRevision = payload.target_revision || '';
3129
const timestamp = payload.timestamp || new Date().toISOString();
3230
const resources = payload.resources || [];
3331
32+
// Determine cluster display
33+
let clusterName = cluster;
34+
let clusterUrl = 'N/A';
35+
36+
if (cluster.startsWith('http')) {
37+
// It's a URL, use as cluster URL
38+
clusterUrl = cluster;
39+
clusterName = cluster.includes('kubernetes.default.svc') ? 'in-cluster' : cluster;
40+
} else {
41+
// It's a friendly name from the label
42+
clusterName = cluster;
43+
}
44+
3445
// Build degraded resources section
3546
let degradedDetails = '';
3647
const degradedResources = resources.filter(r =>
@@ -76,7 +87,6 @@ jobs:
7687
| Field | Value |
7788
|-------|-------|
7889
| Cluster Name | \`${clusterName}\` |
79-
| Cluster URL | \`${clusterUrl}\` |
8090
| Namespace | \`${namespace}\` |
8191
8292
### Application Status
@@ -86,7 +96,6 @@ jobs:
8696
| Health Status | \`${healthStatus}\` |
8797
| Sync Status | \`${syncStatus}\` |
8898
| Revision | \`${revision}\` |
89-
| Target Revision | \`${targetRevision}\` |
9099
| Repository | ${repoUrl} |
91100
92101
### Error Message

0 commit comments

Comments
 (0)