diff options
Diffstat (limited to '.github/workflows/arcade-sync.yml')
-rw-r--r-- | .github/workflows/arcade-sync.yml | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/.github/workflows/arcade-sync.yml b/.github/workflows/arcade-sync.yml new file mode 100644 index 0000000..68cb23d --- /dev/null +++ b/.github/workflows/arcade-sync.yml @@ -0,0 +1,79 @@ +env: + PathToSynchronize: eng\common + SourceRepo: dotnet/arcade + SourceRepoName: arcade + TargetRepo: dotnet/spa-templates + TargetRepoName: spa-templates + +name: Code Sync + +on: + # Manual run + workflow_dispatch: + 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 + # Once per week at midnight PST (8 UTC) on Monday. + - cron: '0 8 * * MON' + +permissions: + contents: write + pull-requests: write + +jobs: + compare_repos: + # Comment out this line to test the scripts in a fork + if: ${{ github.repository == env.TargetRepo }} + name: "Compare the shared code in the given repos; open a PR in the target if they're out of sync." + runs-on: windows-latest + steps: + - name: Checkout ${{ env.SourceRepoName }} + uses: actions/checkout@v3 + with: + repository: ${{ env.SourceRepo }} + path: ${{ env.SourceRepoName }} + ref: main + - name: Checkout ${{ env.TargetRepoName }} + uses: actions/checkout@v3 + with: + repository: ${{ env.TargetRepo }} + path: ${{ env.TargetRepoName }} + ref: main + - name: Copy + shell: cmd + run: ${{ github.workspace }}\${{ env.TargetRepoName }}\.github\workflows\CopyToTarget.cmd + ${{ github.workspace }}\${{ env.SourceRepoName }}\${{ env.PathToSynchronize }} + ${{ github.workspace }}\${{ env.TargetRepoName }}\${{ env.PathToSynchronize }} + - name: Diff + shell: cmd + working-directory: ${{ github.workspace }}\${{ env.TargetRepoName }} + run: | + mkdir ..\artifacts + git status > ..\artifacts\status.txt + git diff > ..\artifacts\diff.txt + - uses: actions/upload-artifact@v3 + with: + name: results + path: artifacts + - name: Check and Notify + id: check + shell: pwsh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + $sendpr = ${{ github.workspace }}\${{ env.TargetRepoName }}\.github\workflows\ReportDiff.ps1 + echo "::set-output name=sendpr::$sendpr" + - name: Send PR + if: steps.check.outputs.sendpr == 'true' + # https://github.com/marketplace/actions/create-pull-request + uses: dotnet/actions-create-pull-request@v3 + with: + base: main + body: 'This PR was automatically generated to sync shared code changes from ${{ env.SourceRepoName }}.' + branch-suffix: timestamp + branch: github-action/sync-${{ env.SourceRepoName }} + commit-message: "Sync shared code from ${{ env.SourceRepoName }}" + labels: area-infrastructure + path: .\${{ env.TargetRepoName }} + title: 'Sync shared code from ${{ env.SourceRepoName }}' + token: ${{ secrets.GITHUB_TOKEN }} |