From 87c4548b27e3bca5dbe71255749880edfd8727e0 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:18:23 +0530 Subject: [PATCH 1/8] changes --- .github/workflows/format-xaml.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 9e72b8288deb..10beb4d47c60 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -7,7 +7,6 @@ jobs: format-xaml: if: github.event.issue.pull_request && github.event.comment.body == '/format' runs-on: ubuntu-latest - environment: Pull Requests defaults: run: shell: pwsh @@ -43,6 +42,9 @@ jobs: # all steps after this one must have the env.CAN_RUN == 1 condition + - uses: actions/checkout@v4 + if: env.CAN_RUN == 1 + - name: Set git identity if: env.CAN_RUN == 1 run: | @@ -55,10 +57,8 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" - - - - uses: actions/checkout@v4 - if: env.CAN_RUN == 1 + git config --local --unset-all http.https://github.com/.extraheader + git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ${{ steps.generate.outputs.token }} - name: Checkout PR if: env.CAN_RUN == 1 @@ -86,8 +86,16 @@ jobs: - name: Commit formatted files if: env.CAN_RUN == 1 run: | - git add . - git commit -m "Formatted XAML files" + git add --renormalize . + if ((git status --porcelain) -eq $null) + { + gh pr comment ${{ github.event.issue.number }} -b "No XAML files changed." + "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append + } + else + { + git commit -m "Formatted XAML files" + } - name: Push to PR if: env.CAN_RUN == 1 From 97996df52f57220cebb216da907d82d9d28c0e51 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:26:39 +0530 Subject: [PATCH 2/8] fix quotes --- .github/workflows/format-xaml.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 10beb4d47c60..e6ad393210c4 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -17,7 +17,6 @@ jobs: uses: tibdex/github-app-token@v1 with: app_id: ${{ secrets.BOT_APP_ID }} - private_key: ${{ secrets.BOT_PRIVATE_KEY }} @@ -57,8 +56,8 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" - git config --local --unset-all http.https://github.com/.extraheader - git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ${{ steps.generate.outputs.token }} + git config --local --unset-all 'http.https://github.com/.extraheader' + git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: basic ${{ steps.generate.outputs.token }}' - name: Checkout PR if: env.CAN_RUN == 1 From aed16f43ab784163d91bbb31e4d7cef1815fba5e Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:02:13 +0530 Subject: [PATCH 3/8] oof --- .github/workflows/format-xaml.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index e6ad393210c4..442aed404eb7 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -56,8 +56,6 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" - git config --local --unset-all 'http.https://github.com/.extraheader' - git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: basic ${{ steps.generate.outputs.token }}' - name: Checkout PR if: env.CAN_RUN == 1 From f023c37d158c9053e333a5b5495a630bc616e140 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:05:52 +0530 Subject: [PATCH 4/8] test another thing --- .github/workflows/format-xaml.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 442aed404eb7..4d8cda601fbd 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -56,6 +56,8 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" + git config --local --unset-all 'http.https://github.com/.extraheader' + git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: basic ${{ steps.generate.outputs.token }}' - name: Checkout PR if: env.CAN_RUN == 1 @@ -117,15 +119,19 @@ jobs: } }' -F owner=$owner -F name=$name -F number=$number --jq '{Branch: .data.repository.pullRequest.headRef.name, Url: .data.repository.pullRequest.headRepository.url}' | ConvertFrom-Json - $url = [UriBuilder]($data.Url) - $url.UserName = 'Personal Access Token' - $url.Password = '${{ steps.generate.outputs.token }}' - git push $url.Uri.AbsoluteUri pr:$($data.Branch) + # $url = [UriBuilder]($data.Url) + # $url.UserName = 'Personal Access Token' + # $url.Password = '${{ steps.generate.outputs.token }}' + git push $data.Url pr:$($data.Branch) if ($LASTEXITCODE -eq 0) { gh pr comment ${{ github.event.issue.number }} -b "Successfully formatted XAML files." } + else + { + "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append + } continue-on-error: true - name: Comment if failed From 8abc5039585b7e4d65451eac86d3f2fb2570c951 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:26:20 +0530 Subject: [PATCH 5/8] try another thing (fml) --- .github/workflows/format-xaml.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 4d8cda601fbd..8b1c14bccc12 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -14,11 +14,10 @@ jobs: steps: - name: Generate GitHub Apps token id: generate - uses: tibdex/github-app-token@v1 + uses: actions/create-github-app-token@v1 with: - app_id: ${{ secrets.BOT_APP_ID }} - private_key: ${{ secrets.BOT_PRIVATE_KEY }} - + app-id: ${{ secrets.BOT_APP_ID }} + private-key: ${{ secrets.BOT_PRIVATE_KEY }} - name: Create run condition variable run: | @@ -57,7 +56,7 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" git config --local --unset-all 'http.https://github.com/.extraheader' - git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: basic ${{ steps.generate.outputs.token }}' + git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: bearer ${{ steps.generate.outputs.token }}' - name: Checkout PR if: env.CAN_RUN == 1 From 8e994580e81a75ee5f058e7b5cf0da0d81828637 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:31:29 +0530 Subject: [PATCH 6/8] oh my GOD --- .github/workflows/format-xaml.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 8b1c14bccc12..86374431e72f 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -55,8 +55,6 @@ jobs: git config --global user.name "$($data.login)" git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" - git config --local --unset-all 'http.https://github.com/.extraheader' - git config --local 'http.https://github.com/.extraheader' 'AUTHORIZATION: bearer ${{ steps.generate.outputs.token }}' - name: Checkout PR if: env.CAN_RUN == 1 @@ -118,10 +116,10 @@ jobs: } }' -F owner=$owner -F name=$name -F number=$number --jq '{Branch: .data.repository.pullRequest.headRef.name, Url: .data.repository.pullRequest.headRepository.url}' | ConvertFrom-Json - # $url = [UriBuilder]($data.Url) - # $url.UserName = 'Personal Access Token' - # $url.Password = '${{ steps.generate.outputs.token }}' - git push $data.Url pr:$($data.Branch) + $url = [UriBuilder]($data.Url) + $url.UserName = 'x-access-token' + $url.Password = '${{ steps.generate.outputs.token }}' + git push $url.Uri.AbsoluteUri pr:$($data.Branch) if ($LASTEXITCODE -eq 0) { From cd82b9692d5fa553b98a5ecaafc9be39d812e276 Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:37:22 +0530 Subject: [PATCH 7/8] hmm --- .github/workflows/format-xaml.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 86374431e72f..2f678a569e55 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -83,6 +83,7 @@ jobs: if: env.CAN_RUN == 1 run: | git add --renormalize . + git status --porcelain if ((git status --porcelain) -eq $null) { gh pr comment ${{ github.event.issue.number }} -b "No XAML files changed." From 698428937e9040a721399ceb8380ac8edeb24fbb Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:39:42 +0530 Subject: [PATCH 8/8] h --- .github/workflows/format-xaml.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml index 2f678a569e55..ebe9a94530a9 100644 --- a/.github/workflows/format-xaml.yml +++ b/.github/workflows/format-xaml.yml @@ -82,7 +82,7 @@ jobs: - name: Commit formatted files if: env.CAN_RUN == 1 run: | - git add --renormalize . + git add --renormalize *.xaml git status --porcelain if ((git status --porcelain) -eq $null) {