Skip to content

Commit 2467df6

Browse files
committed
add discord card messages
1 parent 60cda02 commit 2467df6

File tree

2 files changed

+50
-17
lines changed

2 files changed

+50
-17
lines changed

.github/workflows/build-ubuntu.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,30 @@ jobs:
5050

5151
- name: Build
5252
run: cmake --build build
53+
54+
- name: Discord notification
55+
if: always() && env.DISCORD_WEBHOOK_URL != ''
56+
shell: pwsh
57+
env:
58+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
59+
run: |
60+
$status = if ("${{ job.status }}" -eq "success") { "Success" } else { "Failure" }
61+
$color = if ("${{ job.status }}" -eq "success") { 3066993 } else { 15158332 }
62+
$title = "Ubuntu build $status"
63+
$runUrl = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
64+
$payload = @{
65+
username = "GitHub Actions"
66+
embeds = @(
67+
@{
68+
title = $title
69+
url = $runUrl
70+
color = $color
71+
fields = @(
72+
@{ name = "Commit"; value = "${{ github.sha }}"; inline = $true }
73+
@{ name = "Branch"; value = "${{ github.ref_name }}"; inline = $true }
74+
)
75+
}
76+
)
77+
} | ConvertTo-Json -Depth 5
78+
79+
Invoke-RestMethod -Method Post -Uri $env:DISCORD_WEBHOOK_URL -ContentType "application/json" -Body $payload

.github/workflows/build.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,30 @@ jobs:
6161
run: |
6262
aws s3 cp "$env:ZIP_NAME" "s3://openfodder-builds/$env:ZIP_NAME" --acl public-read
6363
64-
- name: Discord notify (success)
65-
if: ${{ success() }}
64+
- name: Discord notification
65+
if: always() && env.DISCORD_WEBHOOK_URL != ''
6666
shell: pwsh
67-
run: |
68-
$payload = @{
69-
content = "OpenFodder Editor build succeeded: $env:ZIP_NAME"
70-
} | ConvertTo-Json -Compress
71-
Invoke-RestMethod -Uri $env:WEBHOOK_URL -Method Post -ContentType "application/json" -Body $payload
7267
env:
73-
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
74-
75-
- name: Discord notify (failure)
76-
if: ${{ failure() }}
77-
shell: pwsh
68+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
7869
run: |
70+
$status = if ("${{ job.status }}" -eq "success") { "Success" } else { "Failure" }
71+
$color = if ("${{ job.status }}" -eq "success") { 3066993 } else { 15158332 }
72+
$title = "Windows build $status (x64)"
73+
$runUrl = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
7974
$payload = @{
80-
content = "OpenFodder Editor build failed."
81-
} | ConvertTo-Json -Compress
82-
Invoke-RestMethod -Uri $env:WEBHOOK_URL -Method Post -ContentType "application/json" -Body $payload
83-
env:
84-
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
75+
username = "GitHub Actions"
76+
embeds = @(
77+
@{
78+
title = $title
79+
url = $runUrl
80+
color = $color
81+
fields = @(
82+
@{ name = "Commit"; value = "${{ github.sha }}"; inline = $true }
83+
@{ name = "Branch"; value = "${{ github.ref_name }}"; inline = $true }
84+
@{ name = "Config"; value = "Release"; inline = $true }
85+
)
86+
}
87+
)
88+
} | ConvertTo-Json -Depth 5
89+
90+
Invoke-RestMethod -Method Post -Uri $env:DISCORD_WEBHOOK_URL -ContentType "application/json" -Body $payload

0 commit comments

Comments
 (0)