Skip to content

Commit 700b4e9

Browse files
authored
notification action (#20)
* notification action notification action typo * retiring ubuntu22 * fixing branch name in alert
1 parent 8b3c64c commit 700b4e9

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

.cicd/platforms.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"ubuntu22": {
3-
"dockerfile": ".cicd/platforms/ubuntu22.Dockerfile"
4-
},
52
"ubuntu24": {
63
"dockerfile": ".cicd/platforms/ubuntu24.Dockerfile"
74
}
File renamed without changes.
File renamed without changes.

.github/workflows/build.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
strategy:
6363
fail-fast: false
6464
matrix:
65-
platform: [ubuntu22, ubuntu24]
65+
platform: [ubuntu24]
6666
runs-on: ubuntu-24.04
6767
container: ${{fromJSON(needs.discover.outputs.p)[matrix.platform].image}}
6868
steps:
@@ -133,3 +133,61 @@ jobs:
133133
# with:
134134
# name: cdt_ubuntu_package_amd64
135135
# path: build/packages/cdt*amd64.deb
136+
notification:
137+
name: Send Notification
138+
needs: [discover, build-platforms, Build]
139+
if: always()
140+
runs-on: ubuntu-latest
141+
steps:
142+
- name: Send Mattermost Notification
143+
if: always()
144+
env:
145+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
146+
run: |
147+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
148+
BRANCH="${{ github.head_ref }}"
149+
else
150+
BRANCH="${{ github.ref_name }}"
151+
fi
152+
153+
# Determine overall status
154+
if [[ "${{ needs.discover.result }}" == "success" && \
155+
("${{ needs.build-platforms.result }}" == "success" || "${{ needs.build-platforms.result }}" == "skipped") && \
156+
"${{ needs.Build.result }}" == "success" ]]; then
157+
STATUS="✅ SUCCESS"
158+
COLOR="#00FF00"
159+
else
160+
STATUS="❌ FAILURE"
161+
COLOR="#FF0000"
162+
fi
163+
164+
# Build job status details
165+
JOB_DETAILS=""
166+
[[ "${{ needs.discover.result }}" != "success" ]] && JOB_DETAILS="${JOB_DETAILS}\n- **Discover Platforms**: ❌ ${{ needs.discover.result }}"
167+
[[ "${{ needs.build-platforms.result }}" != "success" && "${{ needs.build-platforms.result }}" != "skipped" ]] && JOB_DETAILS="${JOB_DETAILS}\n- **Build Platforms**: ❌ ${{ needs.build-platforms.result }}"
168+
[[ "${{ needs.Build.result }}" != "success" ]] && JOB_DETAILS="${JOB_DETAILS}\n- **Build & Test**: ❌ ${{ needs.Build.result }}"
169+
170+
# Add PR-specific info if applicable
171+
PR_INFO=""
172+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
173+
PR_INFO="\n**PR**: [#${{ github.event.pull_request.number }}](${{ github.event.pull_request.html_url }})"
174+
fi
175+
176+
# Create message payload
177+
PAYLOAD=$(cat <<EOF
178+
{
179+
"channel": "cicd-notifications",
180+
"username": "GitHub Actions",
181+
"icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
182+
"attachments": [{
183+
"color": "$COLOR",
184+
"title": "$STATUS: CDT Build & Test",
185+
"text": "**Repository**: ${{ github.repository }}\n**Branch**: $BRANCH${PR_INFO}\n**Commit**: [\`${GITHUB_SHA::7}\`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})\n**Triggered by**: ${{ github.actor }}\n**Workflow Run**: [View Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})${JOB_DETAILS}"
186+
}]
187+
}
188+
EOF
189+
)
190+
191+
curl -X POST "$WEBHOOK_URL" \
192+
-H "Content-Type: application/json" \
193+
-d "$PAYLOAD"

0 commit comments

Comments
 (0)