Skip to content

Commit

Permalink
Pass branch to snapshot script
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Dec 3, 2024
1 parent 939b4a8 commit c413c40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
- name: Process test results
if: ${{ success() || failure() }}
shell: pwsh
run: ./eng/process-test-results.ps1
run: ./eng/process-test-results.ps1 -Branch "${{ github.ref_name }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 8 additions & 10 deletions eng/process-test-results.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[CmdletBinding(PositionalBinding=$false)]
param (
$branch = $null,
[switch]$dry = $false
)

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

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

# Avoid making new PR against snapshot-updating PR.
if ($currentBranch.StartsWith("update-snapshots")) {
Expand All @@ -22,15 +24,11 @@ if (git status --porcelain) {
}

git branch -D update-snapshots/$currentBranch
git checkout -b update-snapshots/$currentBranch
try {
git commit -am "Update snapshots"
git push -f origin update-snapshots/$currentBranch
gh pr create --base $currentBranch --title "Update snapshots" `
--body "Generate automatically by script ``process-test-results.ps1``."
} finally {
git checkout $currentBranch
}
git checkout -b update-snapshots/
git commit -am "Update snapshots"
git push -f origin update-snapshots/$currentBranch
gh pr create --base $currentBranch --title "Update snapshots" `
--body "Generated automatically by script ``process-test-results.ps1``."
} else {
Write-Output "No changes in snapshots"
}

0 comments on commit c413c40

Please sign in to comment.