From 7ad9e10faaf57e945181888e39a45830a2579168 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 23 Nov 2021 16:01:12 -0800 Subject: [PATCH 1/2] Add a github action to sync shared source from aspnetcore --- .../workflows/aspnetcore-sync-checkdiff.ps1 | 3 + .github/workflows/aspnetcore-sync.yml | 72 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/aspnetcore-sync-checkdiff.ps1 create mode 100644 .github/workflows/aspnetcore-sync.yml diff --git a/.github/workflows/aspnetcore-sync-checkdiff.ps1 b/.github/workflows/aspnetcore-sync-checkdiff.ps1 new file mode 100644 index 00000000000000..b6ff80a408429b --- /dev/null +++ b/.github/workflows/aspnetcore-sync-checkdiff.ps1 @@ -0,0 +1,3 @@ +# Check the code is in sync +$changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0 +return $changed \ No newline at end of file diff --git a/.github/workflows/aspnetcore-sync.yml b/.github/workflows/aspnetcore-sync.yml new file mode 100644 index 00000000000000..1bbc5a188307d5 --- /dev/null +++ b/.github/workflows/aspnetcore-sync.yml @@ -0,0 +1,72 @@ +name: AspNetCore->Runtime Code Sync +on: + # Manual run + workflow_dispatch: + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + compare_repos: + # Comment out this line to test the scripts in a fork + if: github.repository == 'dotnet/runtime' + name: Compare the shared code in the AspNetCore and Runtime repos and send a PR to Runtime if they're out of sync. + runs-on: windows-latest + steps: + - name: Checkout aspnetcore + uses: actions/checkout@v2.0.0 + with: + # Test this script using changes in a fork + repository: 'dotnet/aspnetcore' + # repository: 'tratcher/aspnetcore' + path: aspnetcore + ref: main + - name: Checkout runtime + uses: actions/checkout@v2.0.0 + with: + # Test this script using changes in a fork + repository: 'dotnet/runtime' + # repository: 'tratcher/runtime' + path: runtime + ref: main + - name: Copy + shell: cmd + working-directory: .\aspnetcore\src\Shared\runtime\ + env: + RUNTIME_REPO: d:\a\runtime\runtime\runtime\ + run: CopyToRuntime.cmd + - name: Diff + shell: cmd + working-directory: .\runtime\ + run: | + mkdir ..\artifacts + git status > ..\artifacts\status.txt + git diff > ..\artifacts\diff.txt + - uses: actions/upload-artifact@v1 + with: + name: results + path: artifacts + - name: Check + id: check + shell: pwsh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + $changed = .\runtime\.github\workflows\aspnetcore-sync-checkdiff.ps1 + echo "::set-output name=changed::$changed" + - name: Send PR + if: steps.check.outputs.changed == 'true' + # https://github.com/marketplace/actions/create-pull-request + uses: dotnet/actions-create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: .\runtime + commit-message: 'Sync shared code from aspnetcore' + title: 'Sync shared code from aspnetcore' + body: 'This PR was automatically generated to sync shared code changes from aspnetcore. Fixes https://github.com/dotnet/aspnetcore/issues/18943' + labels: area-System.Net.Http + base: main + branch: github-action/sync-aspnetcore + branch-suffix: timestamp From d9e007215ee9f42abbab9836f0d9af0002369c8b Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Tue, 23 Nov 2021 19:14:28 -0800 Subject: [PATCH 2/2] Apply suggestions from code review --- .github/workflows/aspnetcore-sync.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/aspnetcore-sync.yml b/.github/workflows/aspnetcore-sync.yml index 1bbc5a188307d5..01aa3dfdabca60 100644 --- a/.github/workflows/aspnetcore-sync.yml +++ b/.github/workflows/aspnetcore-sync.yml @@ -12,7 +12,7 @@ jobs: compare_repos: # Comment out this line to test the scripts in a fork if: github.repository == 'dotnet/runtime' - name: Compare the shared code in the AspNetCore and Runtime repos and send a PR to Runtime if they're out of sync. + name: Sync Code runs-on: windows-latest steps: - name: Checkout aspnetcore @@ -20,7 +20,6 @@ jobs: with: # Test this script using changes in a fork repository: 'dotnet/aspnetcore' - # repository: 'tratcher/aspnetcore' path: aspnetcore ref: main - name: Checkout runtime @@ -28,7 +27,6 @@ jobs: with: # Test this script using changes in a fork repository: 'dotnet/runtime' - # repository: 'tratcher/runtime' path: runtime ref: main - name: Copy