Skip to content

Commit

Permalink
chore: updated deploy and docs steps
Browse files Browse the repository at this point in the history
  • Loading branch information
scrthq committed Nov 19, 2024
1 parent 18faa2e commit ddcb6d1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-test-deploy-powershell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,35 @@ jobs:
check_name: Test Results - ${{ matrix.os }}
files: |
BuildOutput/TestResults.xml
deploy:
name: Deploy Module
needs:
- build
if: >-
${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
runs-on: ubuntu-latest
environment:
name: powershell-gallery
env:
GitHubPAT: "${{ secrets.GH_PAT }}"
NuGetApiKey: "${{ secrets.PSGALLERY_NUGET_API_KEY }}"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download BuildOutput directory
uses: actions/download-artifact@v4
with:
name: BuildOutput
path: BuildOutput

- name: Deploy Module
shell: pwsh
run: |
. ./build.ps1 -Task Deploy
- name: Update Docs
shell: pwsh
run: |
. ./build.ps1 -Task Docs
26 changes: 7 additions & 19 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,23 @@ else {
Add-Heading "Finalizing build prerequisites"
if (
$Task -eq 'Deploy' -and -not $Force -and (
$ENV:BUILD_BUILDURI -notlike 'vstfs:*' -or
$env:BUILD_SOURCEBRANCH -like '*pull*' -or
$env:BUILD_SOURCEVERSIONMESSAGE -notmatch '!deploy' -or
$env:BUILD_SOURCEBRANCHNAME -ne 'main' -or
$PSVersionTable.PSVersion.Major -ne 5 -or
$env:GITHUB_REF -ne 'main' -or
$null -eq $env:NugetApiKey
)
) {
"Task is 'Deploy', but conditions are not correct for deployment:`n" +
" + Current build system is VSTS : $($env:BUILD_BUILDURI -like 'vstfs:*') [$env:BUILD_BUILDURI]`n" +
" + Current branch is main : $($env:BUILD_SOURCEBRANCHNAME -eq 'main') [$env:BUILD_SOURCEBRANCHNAME]`n" +
" + Source is not a pull request : $($env:BUILD_SOURCEBRANCH -notlike '*pull*') [$env:BUILD_SOURCEBRANCH]`n" +
" + Current PS major version is 5 : $($PSVersionTable.PSVersion.Major -eq 5) [$($PSVersionTable.PSVersion.ToString())]`n" +
" + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
" + Build script is not Force ran : $($Force)`n" +
" + Commit message matches '!deploy' : $($env:BUILD_SOURCEVERSIONMESSAGE -match '!deploy') [$env:BUILD_SOURCEVERSIONMESSAGE]`n" +
" + Build script is not Force ran : $($Force)`n" +
" + Current branch is main : $($env:GITHUB_REF -eq 'main') [$env:GITHUB_REF]`n" +
" + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
"Skipping psake for this job!" | Write-Host -ForegroundColor Yellow
exit 0
}
else {
if ($Task -eq 'Deploy') {
"Task is 'Deploy' and conditions are correct for deployment:`n" +
" + Build script is Force ran : $($Force)`n" +
" + Current build system is VSTS : $($env:BUILD_BUILDURI -like 'vstfs:*') [$env:BUILD_BUILDURI]`n" +
" + Current branch is main : $($env:BUILD_SOURCEBRANCHNAME -eq 'main') [$env:BUILD_SOURCEBRANCHNAME]`n" +
" + Source is not a pull request : $($env:BUILD_SOURCEBRANCH -notlike '*pull*') [$env:BUILD_SOURCEBRANCH]`n" +
" + Current PS major version is 5 : $($PSVersionTable.PSVersion.Major -eq 5) [$($PSVersionTable.PSVersion.ToString())]`n" +
" + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
" + Commit message matches '!deploy' : $($env:BUILD_SOURCEVERSIONMESSAGE -match '!deploy') [$env:BUILD_SOURCEVERSIONMESSAGE]"| Write-Host -ForegroundColor Green
" + Build script is Force ran : $($Force)`n" +
" + Current branch is main : $($env:GITHUB_REF -eq 'main') [$env:GITHUB_REF]`n" +
" + NuGet API key is not null : $($null -ne $env:NugetApiKey)"| Write-Host -ForegroundColor Green
}
Write-BuildLog "Resolving necessary modules"
foreach ($module in $moduleDependencies) {
Expand Down
2 changes: 1 addition & 1 deletion psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ $deployScriptBlock = {
}
$result = Invoke-RestMethod @uploadParams
}
if (($ENV:BHBuildSystem -eq 'VSTS' -and $env:BHCommitMessage -match '!deploy' -and $env:BHBranchName -eq "main") -or $global:ForceDeploy -eq $true) {
if (($ENV:BHBuildSystem -eq 'VSTS' -and $env:BHBranchName -eq "main") -or $global:ForceDeploy -eq $true) {
if ($null -eq (Get-Module PoshTwit -ListAvailable)) {
" Installing PoshTwit module..."
Install-Module PoshTwit -Scope CurrentUser
Expand Down

0 comments on commit ddcb6d1

Please sign in to comment.