File tree Expand file tree Collapse file tree 2 files changed +45
-30
lines changed Expand file tree Collapse file tree 2 files changed +45
-30
lines changed Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Includes `lastBuild.json`
4+ . DESCRIPTION
5+ Includes the content for `lastBuild.json`.
6+
7+ This should be called after the build to produce information about this build.
8+ . EXAMPLE
9+ ./lastBuild.json.ps1
10+ #>
11+ # region lastBuild.json
12+ # We create a new object each time, so we can use it to compare to the last build.
13+ if (-not $site.LastBuildTime ) { return }
14+ if (-not $buildEnd -and $buildStart ) { return }
15+ $newLastBuild = [Ordered ]@ {
16+ LastBuildTime = $lastBuildTime
17+ BuildDuration = $buildEnd - $buildStart
18+ Message =
19+ if ($gitHubEvent.commits ) {
20+ $gitHubEvent.commits [-1 ].Message
21+ } elseif ($gitHubEvent.schedule ) {
22+ " Ran at $ ( [DateTime ]::Now.ToString(' o' )) on $ ( $gitHubEvent.schedule ) "
23+ } else {
24+ ' On Demand'
25+ }
26+ }
27+
28+ # If we have a CNAME, we can use it to get the last build time from the server.
29+ $lastBuild =
30+ try {
31+ Invoke-RestMethod - Uri " https://$CNAME /lastBuild.json" - ErrorAction Ignore
32+ } catch {
33+ Write-Verbose ($_ | Out-String )
34+ }
35+
36+ # If we could get the last build time, we can use it to calculate the time since the last build.
37+ if ($lastBuild ) {
38+ $newLastBuild.TimeSinceLastBuild = $lastBuildTime - $lastBuild.LastBuildTime
39+ }
40+
41+ # Save the build time to a file.
42+ $newLastBuild | ConvertTo-Json - Depth 2
43+ # endregion lastBuild.json
Original file line number Diff line number Diff line change @@ -117,38 +117,10 @@ if ($PSScriptRoot -and "$PSScriptRoot" -ne "$pwd") {
117117 Push-Location $psScriptRoot
118118}
119119
120- # region lastBuild.json
121- # We create a new object each time, so we can use it to compare to the last build.
122- $newLastBuild = [Ordered ]@ {
123- LastBuildTime = $lastBuildTime
124- BuildDuration = $buildEnd - $buildStart
125- Message =
126- if ($gitHubEvent.commits ) {
127- $gitHubEvent.commits [-1 ].Message
128- } elseif ($gitHubEvent.schedule ) {
129- " Ran at $ ( [DateTime ]::Now.ToString(' o' )) on $ ( $gitHubEvent.schedule ) "
130- } else {
131- ' On Demand'
132- }
120+ if ($site.includes .' LastBuild.json' -is [Management.Automation.ExternalScriptInfo ]) {
121+ . $site.includes .' LastBuild.json'
133122}
134123
135- # If we have a CNAME, we can use it to get the last build time from the server.
136- $lastBuild =
137- try {
138- Invoke-RestMethod - Uri " https://$CNAME /lastBuild.json" - ErrorAction Ignore
139- } catch {
140- Write-Verbose ($_ | Out-String )
141- }
142-
143- # If we could get the last build time, we can use it to calculate the time since the last build.
144- if ($lastBuild ) {
145- $newLastBuild.TimeSinceLastBuild = $lastBuildTime - $lastBuild.LastBuildTime
146- }
147-
148- # Save the build time to a file.
149- $newLastBuild | ConvertTo-Json - Depth 2 > lastBuild.json
150- # endregion lastBuild.json
151-
152124# region index.rss
153125if (-not $Site.NoRss ) {
154126 $pagesByDate = @ ($site.PagesByUrl.GetEnumerator () |
You can’t perform that action at this time.
0 commit comments