workflow, docs update #150
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
name: Increment Build | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
Increment-Build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Update Build Version | |
shell: pwsh | |
env: | |
commitmessage: ${{ github.event.head_commit.message }} | |
run : | | |
$Branch = git rev-parse --abbrev-ref HEAD | |
$Build = Get-Content Modules/ibPS/Functions/Misc/build.json | ConvertFrom-Json | |
if ($ENV:commitmessage -like "*docs*") { | |
Write-Host "Documentation only update. Skipping build version change." | |
} else { | |
$Build.Build = [Int]$Build.build+1 | |
$Build.SHA = $ENV:GITHUB_SHA | |
} | |
$Build.Branch = $Branch | |
Set-Content -Path Modules/ibPS/Functions/Misc/build.json -Value $($Build | ConvertTo-Json) | |
Write-Output "BuildVersion=$($Build.build)" | Out-File -FilePath $ENV:GITHUB_ENV -Encoding utf8 -Append | |
- name: Update Repository | |
run: | | |
git config --global user.name ${{ github.actor }} | |
git config --global user.password ${{ secrets.GIT_ACTIONS }} | |
git config --global user.email 'mat.cox@tmmn.uk' | |
git add . | |
git status | |
if ! git diff-index --quiet HEAD; then | |
git commit -m "Updated Build Version (${{ env.BuildVersion }})" | |
git push | |
else | |
echo "Build Version Not Changed." | |
fi |