Skip to content

Commit 147be38

Browse files
authored
Cleanup the runtime code sync github action (#19173)
1 parent b125c76 commit 147be38

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

.github/workflows/ReportDiff.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Check the code is in sync
2+
$changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
3+
if (-not $changed) { exit }
4+
# Check if tracking issue is open/closed
5+
$Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
6+
$result = Invoke-RestMethod -Uri $issue
7+
if ($result.state -eq "closed") {
8+
$json = "{ `"state`": `"open`" }"
9+
$result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
10+
}
11+
# Add a comment
12+
$status = [IO.File]::ReadAllText("artifacts\status.txt")
13+
$diff = [IO.File]::ReadAllText("artifacts\diff.txt")
14+
$body = @"
15+
The shared code is out of sync.
16+
<details>
17+
<summary>The Diff</summary>
18+
19+
``````
20+
$status
21+
$diff
22+
``````
23+
24+
</details>
25+
"@
26+
$json = ConvertTo-Json -InputObject @{ 'body' = $body }
27+
$issue = $issue + '/comments'
28+
$result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json

.github/workflows/runtime-sync.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@ jobs:
1717
uses: actions/[email protected]
1818
with:
1919
# Test this script using changes in a fork
20-
# repository: 'Tratcher/aspnetcore'
2120
repository: 'dotnet/aspnetcore'
2221
path: aspnetcore
2322
- name: Checkout runtime
2423
uses: actions/[email protected]
2524
with:
2625
# Test this script using changes in a fork
27-
# repository: 'Tratcher/runtime'
2826
repository: 'dotnet/runtime'
2927
path: runtime
3028
- name: Copy
3129
shell: cmd
3230
working-directory: .\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\
3331
env:
3432
ASPNETCORE_REPO: d:\a\aspnetcore\aspnetcore\aspnetcore\
35-
run: |
36-
dir
37-
CopyToAspNetCore.cmd
33+
run: CopyToAspNetCore.cmd
3834
- name: Diff
3935
shell: cmd
4036
working-directory: .\aspnetcore\
@@ -51,34 +47,6 @@ jobs:
5147
env:
5248
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5349
run: |
54-
# Check the code is in sync
55-
$changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
56-
if (-not $changed) { exit }
5750
# Test this script using an issue in the local forked repo
58-
# $issue = 'https://api.github.com/repos/Tratcher/aspnetcore/issues/1'
5951
$issue = 'https://api.github.com/repos/dotnet/aspnetcore/issues/18943'
60-
# Check if tracking issue is open/closed
61-
$Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
62-
$result = Invoke-RestMethod -Uri $issue
63-
if ($result.state -eq "closed") {
64-
$json = "{ `"state`": `"open`" }"
65-
$result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
66-
}
67-
# Add a comment
68-
$status = [IO.File]::ReadAllText("artifacts\status.txt")
69-
$diff = [IO.File]::ReadAllText("artifacts\diff.txt")
70-
$body = @"
71-
The shared code is out of sync.
72-
<details>
73-
<summary>The Diff</summary>
74-
75-
``````
76-
$status
77-
$diff
78-
``````
79-
80-
</details>
81-
"@
82-
$json = ConvertTo-Json -InputObject @{ 'body' = $body }
83-
$issue = $issue + '/comments'
84-
$result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json
52+
.\aspnetcore\.github\workflows\ReportDiff.ps1

0 commit comments

Comments
 (0)