Simplify Program.cs #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Orchard Core Contrib Testing - Update Submodule | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - 'README.md' | |
| jobs: | |
| update-submodules: | |
| runs-on: windows-latest | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| steps: | |
| - name: Checkout OrchardCoreContrib | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: OrchardCoreContrib/OrchardCoreContrib | |
| submodules: true | |
| token: ${{ secrets.OCC_TOKEN }} | |
| - name: Capture Current Submodule Commit Hash | |
| id: submodule-old | |
| shell: pwsh | |
| run: | | |
| $line = (git submodule status --recursive | Select-Object -First 1).Trim() | |
| $parts = $line -split '\s+' | |
| $hash = $parts[0].TrimStart('-','+') | |
| $path = $parts[1] | |
| "hash=$hash" >> $env:GITHUB_OUTPUT | |
| "path=$path" >> $env:GITHUB_OUTPUT | |
| - name: Update submodule | |
| run: | | |
| git submodule sync --recursive | |
| git submodule update --init --recursive | |
| git submodule update --recursive --remote | |
| - name: Capture Updated Submodule Details | |
| id: submodule-new | |
| shell: pwsh | |
| env: | |
| OLD_HASH: ${{ steps.submodule-old.outputs.hash }} | |
| SUBMODULE_PATH: ${{ steps.submodule-old.outputs.path }} | |
| run: | | |
| $line = (git submodule status --recursive | Select-Object -First 1).Trim() | |
| $newHash = ($line -split '\s+')[0].TrimStart('-','+') | |
| $repoUrl = (git -C $env:SUBMODULE_PATH config --get remote.origin.url).Trim() | |
| if ($repoUrl -match '^git@github\.com:(.+)\.git$') { | |
| $repoUrl = "https://github.com/$($Matches[1])" | |
| } else { | |
| $repoUrl = $repoUrl -replace '\.git$','' | |
| } | |
| $repoName = $repoUrl.Split('/')[-1] | |
| $oldShort = $env:OLD_HASH.Substring(0,7) | |
| $newShort = $newHash.Substring(0,7) | |
| "repoUrl=$repoUrl" >> $env:GITHUB_OUTPUT | |
| "repoName=$repoName" >> $env:GITHUB_OUTPUT | |
| "oldHash=$($env:OLD_HASH)" >> $env:GITHUB_OUTPUT | |
| "newHash=$newHash" >> $env:GITHUB_OUTPUT | |
| "oldShort=$oldShort" >> $env:GITHUB_OUTPUT | |
| "newShort=$newShort" >> $env:GITHUB_OUTPUT | |
| "oldCommitUrl=$repoUrl/commit/$($env:OLD_HASH)" >> $env:GITHUB_OUTPUT | |
| "newCommitUrl=$repoUrl/commit/$newHash" >> $env:GITHUB_OUTPUT | |
| "compareUrl=$repoUrl/compare/$($env:OLD_HASH)...$newHash" >> $env:GITHUB_OUTPUT | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.OCC_TOKEN }} | |
| commit-message: Update submodule to latest version | |
| title: Update OrchardCoreContrib.Testing Submodule Version | |
| body: | | |
| Updated [${{ steps.submodule-new.outputs.repoName }}](${{ steps.submodule-new.outputs.repoUrl }}) from ${{ steps.submodule-new.outputs.oldShort }} to ${{ steps.submodule-new.outputs.newShort }}. | |
| <details> | |
| <summary>Details</summary> | |
| _This automated submodule update was generated by workflow._ | |
| - Old commit: [${{ steps.submodule-new.outputs.oldShort }}](${{ steps.submodule-new.outputs.oldCommitUrl }}) | |
| - New commit: [${{ steps.submodule-new.outputs.newShort }}](${{ steps.submodule-new.outputs.newCommitUrl }}) | |
| [View changes](${{ steps.submodule-new.outputs.compareUrl }}) | |
| </details> | |
| branch: update-submodule | |
| delete-branch: true | |
| base: main | |
| labels: | | |
| dependencies | |
| submodule |