Skip to content

Commit dd10a8a

Browse files
committed
Run format workflow on Windows instead of macOS
1 parent 9235d02 commit dd10a8a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/format-code.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Format Code
1313
# Run on 'macos' because Linux is missing the `ios` workload: https://github.com/dotnet/runtime/issues/85505
1414
# Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703
15-
runs-on: macos-15
15+
runs-on: windows-latest
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
@@ -40,4 +40,5 @@ jobs:
4040
# we need to pass the current branch, otherwise we can't commit the changes.
4141
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
4242
- name: Commit Formatted Code
43-
run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF
43+
shell: pwsh
44+
run: pwsh ./scripts/commit-formatted-code.ps1 $GITHUB_HEAD_REF

scripts/commit-formatted-code.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Requires at least PowerShell 5.1 or PowerShell Core
2+
3+
param (
4+
[string]$GITHUB_BRANCH
5+
)
6+
7+
$gitStatus = git status
8+
9+
if ($gitStatus -match "nothing to commit") {
10+
Write-Host "Nothing to commit. All code formatted correctly."
11+
} else {
12+
Write-Host "Formatted some code. Going to push the changes."
13+
git config --global user.name 'Sentry Github Bot'
14+
git config --global user.email '[email protected]'
15+
git fetch
16+
git checkout $GITHUB_BRANCH
17+
git commit -am "Format code"
18+
git push --set-upstream origin $GITHUB_BRANCH
19+
}

0 commit comments

Comments
 (0)