From 87037b84e06129d76dd531b814bd6bb07aca8996 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 24 Feb 2020 16:27:48 -0800 Subject: [PATCH] Automatically send a PR for runtime changes (#19305) --- .github/workflows/ReportDiff.ps1 | 3 ++- .github/workflows/runtime-sync.yml | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ReportDiff.ps1 b/.github/workflows/ReportDiff.ps1 index 5a49187e74..2093a9dd86 100644 --- a/.github/workflows/ReportDiff.ps1 +++ b/.github/workflows/ReportDiff.ps1 @@ -1,6 +1,6 @@ # Check the code is in sync $changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0 -if (-not $changed) { exit } +if (-not $changed) { return $changed } # Check if tracking issue is open/closed $Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; }; $result = Invoke-RestMethod -Uri $issue @@ -26,3 +26,4 @@ $diff $json = ConvertTo-Json -InputObject @{ 'body' = $body } $issue = $issue + '/comments' $result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json +return $changed \ No newline at end of file diff --git a/.github/workflows/runtime-sync.yml b/.github/workflows/runtime-sync.yml index 5b173f5c0e..8ebda97d21 100644 --- a/.github/workflows/runtime-sync.yml +++ b/.github/workflows/runtime-sync.yml @@ -1,7 +1,7 @@ name: AspNetCore-Runtime Code Sync on: # Test this script using on: push - # push + # push: schedule: # * is a special character in YAML so you have to quote this string # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#scheduled-events-schedule @@ -43,10 +43,25 @@ jobs: name: results path: artifacts - name: Check and Notify + id: check shell: pwsh env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Test this script using an issue in the local forked repo $issue = 'https://api.github.com/repos/dotnet/aspnetcore/issues/18943' - .\aspnetcore\.github\workflows\ReportDiff.ps1 \ No newline at end of file + $changed = .\aspnetcore\.github\workflows\ReportDiff.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: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: .\aspnetcore + commit-message: 'Sync shared code from runtime' + title: 'Sync shared code from runtime' + body: 'This PR was automatically generated to sync shared code changes from runtime. Fixes #18943' + labels: area-servers + branch: github-action/sync-runtime + branch-suffix: timestamp