From 147be384eea84a8152d63c5132570bb02855ac90 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 20 Feb 2020 16:44:12 -0800 Subject: [PATCH] Cleanup the runtime code sync github action (#19173) --- .github/workflows/ReportDiff.ps1 | 28 +++++++++++++++++++++++ .github/workflows/runtime-sync.yml | 36 ++---------------------------- 2 files changed, 30 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ReportDiff.ps1 diff --git a/.github/workflows/ReportDiff.ps1 b/.github/workflows/ReportDiff.ps1 new file mode 100644 index 0000000000..5a49187e74 --- /dev/null +++ b/.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. +
+ The Diff + +`````` +$status +$diff +`````` + +
+"@ +$json = ConvertTo-Json -InputObject @{ 'body' = $body } +$issue = $issue + '/comments' +$result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json diff --git a/.github/workflows/runtime-sync.yml b/.github/workflows/runtime-sync.yml index 66c0cbc192..5b173f5c0e 100644 --- a/.github/workflows/runtime-sync.yml +++ b/.github/workflows/runtime-sync.yml @@ -17,14 +17,12 @@ jobs: uses: actions/checkout@v2.0.0 with: # Test this script using changes in a fork - # repository: 'Tratcher/aspnetcore' repository: 'dotnet/aspnetcore' path: aspnetcore - name: Checkout runtime uses: actions/checkout@v2.0.0 with: # Test this script using changes in a fork - # repository: 'Tratcher/runtime' repository: 'dotnet/runtime' path: runtime - name: Copy @@ -32,9 +30,7 @@ jobs: working-directory: .\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\ env: ASPNETCORE_REPO: d:\a\aspnetcore\aspnetcore\aspnetcore\ - run: | - dir - CopyToAspNetCore.cmd + run: CopyToAspNetCore.cmd - name: Diff shell: cmd working-directory: .\aspnetcore\ @@ -51,34 +47,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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 - # $issue = 'https://api.github.com/repos/Tratcher/aspnetcore/issues/1' $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. -
- The Diff - - `````` - $status - $diff - `````` - -
- "@ - $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 \ No newline at end of file