7
7
format-xaml :
8
8
if : github.event.issue.pull_request && github.event.comment.body == '/format'
9
9
runs-on : ubuntu-latest
10
- environment : Pull Requests
11
10
defaults :
12
11
run :
13
12
shell : pwsh
14
13
15
14
steps :
16
15
- name : Generate GitHub Apps token
17
16
id : generate
18
- uses : tibdex/ github-app-token@v1
17
+ uses : actions/create- github-app-token@v1
19
18
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 }}
24
21
25
22
- name : Create run condition variable
26
23
run : |
43
40
44
41
# all steps after this one must have the env.CAN_RUN == 1 condition
45
42
43
+ - uses : actions/checkout@v4
44
+ if : env.CAN_RUN == 1
45
+
46
46
- name : Set git identity
47
47
if : env.CAN_RUN == 1
48
48
run : |
56
56
git config --global user.name "$($data.login)"
57
57
git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com"
58
58
59
-
60
- - uses : actions/checkout@v4
61
- if : env.CAN_RUN == 1
62
-
63
59
- name : Checkout PR
64
60
if : env.CAN_RUN == 1
65
61
run : gh pr checkout ${{ github.event.issue.number }} -b pr
86
82
- name : Commit formatted files
87
83
if : env.CAN_RUN == 1
88
84
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
+ }
91
96
92
97
- name : Push to PR
93
98
if : env.CAN_RUN == 1
@@ -113,14 +118,18 @@ jobs:
113
118
}' -F owner=$owner -F name=$name -F number=$number --jq '{Branch: .data.repository.pullRequest.headRef.name, Url: .data.repository.pullRequest.headRepository.url}' | ConvertFrom-Json
114
119
115
120
$url = [UriBuilder]($data.Url)
116
- $url.UserName = 'Personal Access Token '
121
+ $url.UserName = 'x-access-token '
117
122
$url.Password = '${{ steps.generate.outputs.token }}'
118
123
git push $url.Uri.AbsoluteUri pr:$($data.Branch)
119
124
120
125
if ($LASTEXITCODE -eq 0)
121
126
{
122
127
gh pr comment ${{ github.event.issue.number }} -b "Successfully formatted XAML files."
123
128
}
129
+ else
130
+ {
131
+ "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append
132
+ }
124
133
continue-on-error : true
125
134
126
135
- name : Comment if failed
0 commit comments