77 format-xaml :
88 if : github.event.issue.pull_request && github.event.comment.body == '/format'
99 runs-on : ubuntu-latest
10- environment : Pull Requests
1110 defaults :
1211 run :
1312 shell : pwsh
1413
1514 steps :
1615 - name : Generate GitHub Apps token
1716 id : generate
18- uses : tibdex/ github-app-token@v1
17+ uses : actions/create- github-app-token@v1
1918 with :
20- app_id : ${{ secrets.BOT_APP_ID }}
21-
22- private_key : ${{ secrets.BOT_PRIVATE_KEY }}
23-
19+ app-id : ${{ secrets.BOT_APP_ID }}
20+ private-key : ${{ secrets.BOT_PRIVATE_KEY }}
2421
2522 - name : Create run condition variable
2623 run : |
4340
4441 # all steps after this one must have the env.CAN_RUN == 1 condition
4542
43+ - uses : actions/checkout@v4
44+ if : env.CAN_RUN == 1
45+
4646 - name : Set git identity
4747 if : env.CAN_RUN == 1
4848 run : |
5656 git config --global user.name "$($data.login)"
5757 git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com"
5858
59-
60- - uses : actions/checkout@v4
61- if : env.CAN_RUN == 1
62-
6359 - name : Checkout PR
6460 if : env.CAN_RUN == 1
6561 run : gh pr checkout ${{ github.event.issue.number }} -b pr
8682 - name : Commit formatted files
8783 if : env.CAN_RUN == 1
8884 run : |
89- git add .
90- git commit -m "Formatted XAML files"
85+ git add --renormalize *.xaml
86+ git status --porcelain
87+ if ((git status --porcelain) -eq $null)
88+ {
89+ gh pr comment ${{ github.event.issue.number }} -b "No XAML files changed."
90+ "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append
91+ }
92+ else
93+ {
94+ git commit -m "Formatted XAML files"
95+ }
9196
9297 - name : Push to PR
9398 if : env.CAN_RUN == 1
@@ -113,14 +118,18 @@ jobs:
113118 }' -F owner=$owner -F name=$name -F number=$number --jq '{Branch: .data.repository.pullRequest.headRef.name, Url: .data.repository.pullRequest.headRepository.url}' | ConvertFrom-Json
114119
115120 $url = [UriBuilder]($data.Url)
116- $url.UserName = 'Personal Access Token '
121+ $url.UserName = 'x-access-token '
117122 $url.Password = '${{ steps.generate.outputs.token }}'
118123 git push $url.Uri.AbsoluteUri pr:$($data.Branch)
119124
120125 if ($LASTEXITCODE -eq 0)
121126 {
122127 gh pr comment ${{ github.event.issue.number }} -b "Successfully formatted XAML files."
123128 }
129+ else
130+ {
131+ "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append
132+ }
124133 continue-on-error : true
125134
126135 - name : Comment if failed
0 commit comments