forked from LunaMultiplayer/LunaMultiplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappveyor_discord.ps
75 lines (65 loc) · 2.45 KB
/
appveyor_discord.ps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Taken from: https://github.com/DiscordHooks/appveyor-discord-webhook
# License: MIT
$STATUS=$args[0]
$WEBHOOK_URL=$args[1]
if (!$WEBHOOK_URL) {
Write-Output "WARNING!!"
Write-Output "You need to pass the WEBHOOK_URL environment variable as the second argument to this script."
Exit
}
$AVATAR="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Appveyor_logo.svg/256px-Appveyor_logo.svg.png"
$GITHUB_LOGO="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png"
$LMP_LOGO="https://raw.githubusercontent.com/LunaMultiplayer/LunaMultiplayer/master/External/Logos/RedFont/LMP_Icon_Medium.png"
$REPO_URL="https://github.com/$env:APPVEYOR_REPO_NAME/"
$URL="https://ci.appveyor.com/project/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_NAME"
$ARTIFACTS_URL="https://ci.appveyor.com/project/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_NAME/build/job/$env:APPVEYOR_JOB_ID/artifacts"
$CLIENT_URL="https://ci.appveyor.com/api/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/LunaMultiplayer-Debug.zip"
$MASTER_SERVER_URL="https://ci.appveyor.com/api/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/LunaMultiplayerMasterServer-Debug.zip"
$BUILD_VERSION = [uri]::EscapeDataString($env:APPVEYOR_BUILD_VERSION)
$TIMESTAMP="$(Get-Date -format s)Z"
Switch ($STATUS) {
"success" {
$EMBED_COLOR=3066993
$STATUS_MESSAGE="Passed"
Break
}
"failure" {
$EMBED_COLOR=15158332
$STATUS_MESSAGE="Failed"
Break
}
default {
Write-Output "Default!"
Break
}
}
$WEBHOOK_DATA="{
""username"": """",
""avatar_url"": ""$AVATAR"",
""content"":"""",
""embeds"": [ {
""color"": $EMBED_COLOR,
""author"": {
""name"": ""Appveyor nightly build"",
""url"": ""$URL"",
""icon_url"": ""$AVATAR""
},
""title"": ""New nightly build available for download - $BUILD_VERSION"",
""url"": ""$ARTIFACTS_URL"",
""description"": ""Keep in mind that nightly builds might contain bugs!"",
""fields"": [
{
""name"": ""Client"",
""value"": ""[Download Link]($CLIENT_URL)""
}
],
""timestamp"": ""$TIMESTAMP"",
""footer"": {
""icon_url"": ""$LMP_LOGO"",
""text"": ""Luna multiplayer""
}
} ]
}"
Write-Output "[Webhook]: Webhook payload data: $WEBHOOK_DATA"
Invoke-RestMethod -Uri "$WEBHOOK_URL" -Method POST -UserAgent "AppVeyor-Webhook" -ContentType "application/json" -Header @{"X-Autho" = "Dagger"} -Body $WEBHOOK_DATA
Write-Output "[Webhook]: Successfully sent the webhook."