Skip to content

Commit 88a8f48

Browse files
committed
improve discord message
1 parent 914ea1c commit 88a8f48

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/linux-build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,29 @@ jobs:
4040
run: cmake -S . -B build -G Ninja
4141
- name: Build
4242
run: cmake --build build
43+
- name: Discord notification
44+
if: always() && env.DISCORD_WEBHOOK_URL != ''
45+
shell: pwsh
46+
env:
47+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
48+
run: |
49+
$status = if ("${{ job.status }}" -eq "success") { "Success" } else { "Failure" }
50+
$color = if ("${{ job.status }}" -eq "success") { 3066993 } else { 15158332 }
51+
$title = "Linux build $status"
52+
$runUrl = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
53+
$payload = @{
54+
username = "GitHub Actions"
55+
embeds = @(
56+
@{
57+
title = $title
58+
url = $runUrl
59+
color = $color
60+
fields = @(
61+
@{ name = "Commit"; value = "${{ github.sha }}"; inline = $true }
62+
@{ name = "Branch"; value = "${{ github.ref_name }}"; inline = $true }
63+
)
64+
}
65+
)
66+
} | ConvertTo-Json -Depth 5
67+
68+
Invoke-RestMethod -Method Post -Uri $env:DISCORD_WEBHOOK_URL -ContentType "application/json" -Body $payload

.github/workflows/windows-build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,30 @@ jobs:
6060
with:
6161
name: OpenFodder-${{ matrix.arch }}-${{ matrix.configuration }}-latest
6262
path: OpenFodder-${{ matrix.arch }}-${{ matrix.configuration }}-latest.zip
63+
- name: Discord notification
64+
if: always() && env.DISCORD_WEBHOOK_URL != ''
65+
shell: pwsh
66+
env:
67+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
68+
run: |
69+
$status = if ("${{ job.status }}" -eq "success") { "Success" } else { "Failure" }
70+
$color = if ("${{ job.status }}" -eq "success") { 3066993 } else { 15158332 }
71+
$title = "Windows build $status (${{ matrix.arch }})"
72+
$runUrl = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
73+
$payload = @{
74+
username = "GitHub Actions"
75+
embeds = @(
76+
@{
77+
title = $title
78+
url = $runUrl
79+
color = $color
80+
fields = @(
81+
@{ name = "Commit"; value = "${{ github.sha }}"; inline = $true }
82+
@{ name = "Branch"; value = "${{ github.ref_name }}"; inline = $true }
83+
@{ name = "Config"; value = "${{ matrix.configuration }}"; inline = $true }
84+
)
85+
}
86+
)
87+
} | ConvertTo-Json -Depth 5
88+
89+
Invoke-RestMethod -Method Post -Uri $env:DISCORD_WEBHOOK_URL -ContentType "application/json" -Body $payload

0 commit comments

Comments
 (0)