Skip to content

Commit 577dfd5

Browse files
committed
Pass branch to snapshot script
1 parent 939b4a8 commit 577dfd5

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
- name: Process test results
3434
if: ${{ success() || failure() }}
3535
shell: pwsh
36-
run: ./eng/process-test-results.ps1
36+
run: ./eng/process-test-results.ps1 -Branch "${{ github.head_ref || github.ref_name }}"
3737
env:
3838
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

eng/process-test-results.ps1

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[CmdletBinding(PositionalBinding=$false)]
22
param (
3+
$branch = $null,
34
[switch]$dry = $false
45
)
56

@@ -8,7 +9,8 @@ $ErrorActionPreference = "Stop"
89

910
# If snapshots are changed, create a pull request.
1011
if (git status --porcelain) {
11-
$currentBranch = $(git branch --show-current)
12+
$currentBranch = $branch ?? $(git branch --show-current)
13+
Write-Output "Branch: '$currentBranch'"
1214

1315
# Avoid making new PR against snapshot-updating PR.
1416
if ($currentBranch.StartsWith("update-snapshots")) {
@@ -23,14 +25,10 @@ if (git status --porcelain) {
2325

2426
git branch -D update-snapshots/$currentBranch
2527
git checkout -b update-snapshots/$currentBranch
26-
try {
27-
git commit -am "Update snapshots"
28-
git push -f origin update-snapshots/$currentBranch
29-
gh pr create --base $currentBranch --title "Update snapshots" `
30-
--body "Generate automatically by script ``process-test-results.ps1``."
31-
} finally {
32-
git checkout $currentBranch
33-
}
28+
git commit -am "Update snapshots"
29+
git push -f origin update-snapshots/$currentBranch
30+
gh pr create --base $currentBranch --title "Update snapshots" `
31+
--body "Generated automatically by script ``process-test-results.ps1``."
3432
} else {
3533
Write-Output "No changes in snapshots"
3634
}

0 commit comments

Comments
 (0)