Răsfoiți Sursa

Cleanup the runtime code sync github action (#19173)

Chris Ross 6 ani în urmă
părinte
comite
147be384ee
2 a modificat fișierele cu 30 adăugiri și 34 ștergeri
  1. 28 0
      .github/workflows/ReportDiff.ps1
  2. 2 34
      .github/workflows/runtime-sync.yml

+ 28 - 0
.github/workflows/ReportDiff.ps1

@@ -0,0 +1,28 @@
+# Check the code is in sync
+$changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
+if (-not $changed) { exit }
+# Check if tracking issue is open/closed
+$Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
+$result = Invoke-RestMethod -Uri $issue
+if ($result.state -eq "closed") { 
+ $json = "{ `"state`": `"open`" }"
+ $result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
+}
+# Add a comment
+$status = [IO.File]::ReadAllText("artifacts\status.txt")
+$diff = [IO.File]::ReadAllText("artifacts\diff.txt")
+$body = @"
+The shared code is out of sync.
+<details>
+  <summary>The Diff</summary>
+
+``````
+$status
+$diff
+``````
+
+</details>
+"@
+$json = ConvertTo-Json -InputObject @{ 'body' = $body }
+$issue = $issue + '/comments'
+$result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json

+ 2 - 34
.github/workflows/runtime-sync.yml

@@ -17,14 +17,12 @@ jobs:
       uses: actions/[email protected]
       uses: actions/[email protected]
       with:
       with:
         # Test this script using changes in a fork 
         # Test this script using changes in a fork 
-        # repository: 'Tratcher/aspnetcore'
         repository: 'dotnet/aspnetcore'
         repository: 'dotnet/aspnetcore'
         path: aspnetcore
         path: aspnetcore
     - name: Checkout runtime
     - name: Checkout runtime
       uses: actions/[email protected]
       uses: actions/[email protected]
       with:
       with:
         # Test this script using changes in a fork 
         # Test this script using changes in a fork 
-        # repository: 'Tratcher/runtime'
         repository: 'dotnet/runtime'
         repository: 'dotnet/runtime'
         path: runtime
         path: runtime
     - name: Copy
     - name: Copy
@@ -32,9 +30,7 @@ jobs:
       working-directory: .\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\
       working-directory: .\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\
       env:
       env:
         ASPNETCORE_REPO: d:\a\aspnetcore\aspnetcore\aspnetcore\
         ASPNETCORE_REPO: d:\a\aspnetcore\aspnetcore\aspnetcore\
-      run: |
-        dir
-        CopyToAspNetCore.cmd
+      run: CopyToAspNetCore.cmd
     - name: Diff
     - name: Diff
       shell: cmd
       shell: cmd
       working-directory: .\aspnetcore\
       working-directory: .\aspnetcore\
@@ -51,34 +47,6 @@ jobs:
       env:
       env:
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       run: |
       run: |
-        # Check the code is in sync
-        $changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
-        if (-not $changed) { exit }
         # Test this script using an issue in the local forked repo
         # Test this script using an issue in the local forked repo
-        # $issue = 'https://api.github.com/repos/Tratcher/aspnetcore/issues/1'
         $issue = 'https://api.github.com/repos/dotnet/aspnetcore/issues/18943'
         $issue = 'https://api.github.com/repos/dotnet/aspnetcore/issues/18943'
-        # Check if tracking issue is open/closed
-        $Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
-        $result = Invoke-RestMethod -Uri $issue
-        if ($result.state -eq "closed") { 
-         $json = "{ `"state`": `"open`" }"
-         $result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
-        }
-        # Add a comment
-        $status = [IO.File]::ReadAllText("artifacts\status.txt")
-        $diff = [IO.File]::ReadAllText("artifacts\diff.txt")
-        $body = @"
-        The shared code is out of sync.
-        <details>
-          <summary>The Diff</summary>
-          
-        ``````
-        $status
-        $diff
-        ``````
-        
-        </details>
-        "@
-        $json = ConvertTo-Json -InputObject @{ 'body' = $body }
-        $issue = $issue + '/comments'
-        $result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json
+        .\aspnetcore\.github\workflows\ReportDiff.ps1