-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop failing GitHub Action nightly build if no changes were detected
- Loading branch information
Showing
2 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,52 +22,63 @@ jobs: | |
run: git checkout master | ||
|
||
- name: Precondition | ||
id: precondition | ||
if: success() | ||
run: .\build\precondition.ps1 | ||
run: | | ||
$result = .\build\precondition.ps1 | ||
$previousHash = $result.PreviousHash | ||
$latestBuildHash = $result.LatestBuildHash | ||
$hasChanges = $result.HasChanges | ||
echo "Previous hash: $previousHash" | ||
echo "Latest build hash: $latestBuildHash" | ||
echo "::set-output name=has_changes::$hasChanges" | ||
- name: Setup MSBuild | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
uses: warrenbuckley/Setup-MSBuild@v1 | ||
|
||
- name: Setup Nuget | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
uses: warrenbuckley/Setup-Nuget@v1 | ||
|
||
- name: Setup Git | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: | | ||
git config user.email [email protected] | ||
git config user.name "GitHub Actions" | ||
- name: Build | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: .\build\build.ps1 nightly Release pack 0 | ||
|
||
- name: Find NUPKG | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: | | ||
$filesInPackDir = (Get-ChildItem -Path pack | Sort-Object -Property @{Expression="Name"; Descending=$true}) | ||
$nupkgFile = $filesInPackDir[0].FullName | ||
echo "::set-env name=NUPKG_FILE::$nupkgFile" | ||
- name: Update nightly.rev | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: .\build\update-nightly-rev.ps1 | ||
|
||
- name: Increment version | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: .\build\increment-build-version.ps1 | ||
|
||
- name: Git Commit | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: | | ||
git add ./build/ExceptionalDevs.Exceptional.nuspec | ||
git add ./build/nightly.rev | ||
git commit -m "Nightly Commit" --author="GitHub Actions<[email protected]>" | ||
- name: Git Push | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish | ||
if: success() | ||
if: steps.precondition.outputs.has_changes == 'true' && success() | ||
run: nuget push ${{ env.NUPKG_FILE }} ${{ secrets.JETBRAINS_TOKEN }} -source https://plugins.jetbrains.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path | ||
$NightlyRevFile = Join-Path -Path $ScriptDir -ChildPath nightly.rev | ||
$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path | ||
$nightlyRevFile = Join-Path -Path $scriptDir -ChildPath nightly.rev | ||
|
||
$PreviousHash = git rev-parse HEAD~1 | ||
$HashOfLatestBuild = Get-Content -Path $NightlyRevFile -ErrorAction SilentlyContinue | ||
$previousHash = git rev-parse HEAD~1 | ||
$hashOfLatestBuild = Get-Content -Path $nightlyRevFile -ErrorAction SilentlyContinue | ||
|
||
Write-Output "Previous hash: $PreviousHash" | ||
Write-Output "Latest Build Hash: $HashOfLatestBuild" | ||
$hasChanges = -Not ($previousHash -eq $hashOfLatestBuild) | ||
|
||
$HasChanges = -Not ($PreviousHash -eq $HashOfLatestBuild) | ||
|
||
if ($HasChanges -eq $true) | ||
{ | ||
"Some changes detected" | ||
exit 0 | ||
} | ||
else | ||
{ | ||
Write-Output "No changes detected" | ||
exit 1 | ||
return @{ | ||
"LatestBuildHash" = $hashOfLatestBuild; | ||
"PreviousHash" = $previousHash; | ||
"HasChanges" = $hasChanges; | ||
} |