-
Notifications
You must be signed in to change notification settings - Fork 5
174 lines (153 loc) · 6.8 KB
/
Win64_DX12_Final.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: "Win64 DX12 Final"
on:
workflow_dispatch:
push:
branches: [ "master" ]
paths:
- '**/*.vcxproj'
- '**/*.h'
- '**/*.hpp'
- '**/*.c'
- '**/*.cpp'
- '**/*.inl'
- '**/*.hlsli'
- '**/*.hlsl.h'
pull_request:
branches: [ "master" ]
paths:
- '**/*.vcxproj'
- '**/*.h'
- '**/*.hpp'
- '**/*.c'
- '**/*.cpp'
- '**/*.inl'
- '**/*.hlsli'
- '**/*.hlsl.h'
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: vgframework.sln
# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Final
# Platform to build.
BUILD_PLATFORM: '"Win64 DX12"'
permissions:
contents: read
jobs:
build_win64_dx12_final:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: '[17.11.2, 18.0.0)'
- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}}
- name: Success Notification
if: ${{ success() }}
run: |
$DISCORD_BUILD_WEBHOOK_URL = "${{ secrets.DISCORD_BUILD_WEBHOOK_URL }}"
$commitMessage = @"
${{ github.event.head_commit.message }}
"@
$jobName = "${{ github.job }}"
$runId = "${{ github.run_id }}"
$repo = "${{ github.repository }}"
$serverUrl = "${{ github.server_url }}"
$jobsApiUrl = "https://api.github.com/repos/$repo/actions/runs/$runId/jobs"
$jobId = (curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $jobsApiUrl | ConvertFrom-Json).jobs | Where-Object { $_.name -eq $jobName } | Select-Object -ExpandProperty id
$jobUrl = "$serverUrl/$repo/actions/runs/$runId/job/$jobId"
$commitSha = "${{ github.sha }}"
$shortCommitSha = $commitSha.Substring(0, 7)
# Split the commit message on double newlines (\r?\n\r?\n) to separate the summary and description. Clean and escape strings to make them JSON-safe
$splitMessage = $commitMessage -split '\r?\n\r?\n', 2
$summary = $splitMessage[0]
$description = if ($splitMessage.Length -gt 1) { $splitMessage[1] } else { "" }
$escapedSummary = $summary -replace '"', '\"' -replace "`r`n", ' ' -replace "`n", ' '
$escapedDescription = $description -replace '"', '\"' -replace "`r`n", ' ' -replace "`n", ' '
$title = "${{ github.workflow }} build succeeded ``$shortCommitSha``"
$jsonPayload = @"
{
"username": "Gros Covid",
"content": "",
"embeds": [
{
"type": "rich",
"title": "$title",
"description": "$escapedSummary",
"color": 38912,
"thumbnail": {
"url": "https://github.com/vimontgames/vgframework/blob/master/doc/img/buildsuccess.png?raw=true"
},
"author": {
"name": "$($env:GITHUB_ACTOR)",
"url": "https://github.com/$($env:GITHUB_ACTOR)",
"icon_url": "https://avatars.githubusercontent.com/u/$($env:GITHUB_ACTOR_ID)?v=4"
},
"url": "$jobUrl"
}
]
}
"@
$RESPONSE = curl -H "Content-Type: application/json" -X POST -d $jsonPayload $DISCORD_BUILD_WEBHOOK_URL
Write-Output "Webhook server response: $RESPONSE"
- name: Failure Notification
if: ${{ failure() }}
run: |
$DISCORD_BUILD_WEBHOOK_URL = "${{ secrets.DISCORD_BUILD_WEBHOOK_URL }}"
$commitMessage = @"
${{ github.event.head_commit.message }}
"@
$jobName = "${{ github.job }}"
$runId = "${{ github.run_id }}"
$repo = "${{ github.repository }}"
$serverUrl = "${{ github.server_url }}"
$jobsApiUrl = "https://api.github.com/repos/$repo/actions/runs/$runId/jobs"
$jobId = (curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $jobsApiUrl | ConvertFrom-Json).jobs | Where-Object { $_.name -eq $jobName } | Select-Object -ExpandProperty id
$jobUrl = "$serverUrl/$repo/actions/runs/$runId/job/$jobId"
$commitSha = "${{ github.sha }}"
$shortCommitSha = $commitSha.Substring(0, 7)
# Split the commit message on double newlines (\r?\n\r?\n) to separate the summary and description. Clean and escape strings to make them JSON-safe
$splitMessage = $commitMessage -split '\r?\n\r?\n', 2
$summary = $splitMessage[0]
$description = if ($splitMessage.Length -gt 1) { $splitMessage[1] } else { "" }
$escapedSummary = $summary -replace '"', '\"' -replace "`r`n", ' ' -replace "`n", ' '
$escapedDescription = $description -replace '"', '\"' -replace "`r`n", ' ' -replace "`n", ' '
$title = "${{ github.workflow }} build failed ``$shortCommitSha``"
$jsonPayload = @"
{
"username": "Gros Covid",
"content": "",
"embeds": [
{
"type": "rich",
"title": "$title",
"description": "$escapedSummary",
"color": 16515049,
"thumbnail": {
"url": "https://github.com/vimontgames/vgframework/blob/master/doc/img/buildfailed.png?raw=true"
},
"author": {
"name": "$($env:GITHUB_ACTOR)",
"url": "https://github.com/$($env:GITHUB_ACTOR)",
"icon_url": "https://avatars.githubusercontent.com/u/$($env:GITHUB_ACTOR_ID)?v=4"
},
"url": "$jobUrl"
}
]
}
"@
$RESPONSE = curl -H "Content-Type: application/json" -X POST -d $jsonPayload $DISCORD_BUILD_WEBHOOK_URL
Write-Output "Webhook server response: $RESPONSE"