@@ -14,6 +14,9 @@ inputs:
1414 InstallModule :
1515 required : false
1616 description : A list of modules to be installed from the PowerShell gallery before scripts run.
17+ TargetBranch :
18+ required : false
19+ description : If provided, will checkout a new branch before making the changes.
1720 CommitMessage :
1821 required : false
1922 description : If provided, will commit any remaining changes made to the workspace with this commit message.
@@ -39,13 +42,15 @@ runs:
3942 PSJekyllScript : ${{inputs.PSJekyllScript}}
4043 CommitMessage : ${{inputs.CommitMessage}}
4144 UserName : ${{inputs.UserName}}
45+ TargetBranch : ${{inputs.TargetBranch}}
4246 run : |
4347 $Parameters = @{}
4448 $Parameters.PSJekyllScript = ${env:PSJekyllScript}
4549 $Parameters.SkipPSJekyllPS1 = ${env:SkipPSJekyllPS1}
4650 $Parameters.SkipPSJekyllPS1 = $parameters.SkipPSJekyllPS1 -match 'true';
4751 $Parameters.InstallModule = ${env:InstallModule}
4852 $Parameters.InstallModule = $parameters.InstallModule -split ';' -replace '^[''"]' -replace '[''"]$'
53+ $Parameters.TargetBranch = ${env:TargetBranch}
4954 $Parameters.CommitMessage = ${env:CommitMessage}
5055 $Parameters.UserEmail = ${env:UserEmail}
5156 $Parameters.UserName = ${env:UserName}
8792 [string[]]
8893 $InstallModule,
8994
95+ # If provided, will checkout a new branch before making the changes.
96+ [string]
97+ $TargetBranch,
98+
9099 # If provided, will commit any remaining changes made to the workspace with this commit message.
91100 [string]
92101 $CommitMessage,
@@ -172,6 +181,14 @@ runs:
172181
173182 # Pull down any changes
174183 git pull | Out-Host
184+
185+ if ($TargetBranch) {
186+ "::notice title=Expanding target branch string $targetBranch" | Out-Host
187+ $TargetBranch = $ExecutionContext.SessionState.InvokeCommand.ExpandString($TargetBranch)
188+ "::notice title=Checking out target branch::$targetBranch" | Out-Host
189+ git checkout -b $TargetBranch | Out-Host
190+ git pull | Out-Host
191+ }
175192 }
176193
177194 function InvokeActionModule {
@@ -284,7 +301,11 @@ runs:
284301 $checkDetached = git symbolic-ref -q HEAD
285302 if (-not $LASTEXITCODE) {
286303 "::notice::Pushing Changes" | Out-Host
287- git push
304+ if ($TargetBranch -and $anyFilesChanged) {
305+ git push --set-upstream origin $TargetBranch
306+ } elseif ($anyFilesChanged) {
307+ git push
308+ }
288309 "Git Push Output: $($gitPushed | Out-String)"
289310 } else {
290311 "::notice::Not pushing changes (on detached head)" | Out-Host
0 commit comments