Skip to content

Commit 3d6946c

Browse files
committed
Add update-submodule.yml
1 parent c1aa727 commit 3d6946c

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Orchard Core Contrib Testing - Update Submodule
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- 'README.md'
8+
9+
jobs:
10+
update-submodules:
11+
runs-on: windows-latest
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14+
DOTNET_CLI_TELEMETRY_OPTOUT: true
15+
16+
steps:
17+
- name: Checkout OrchardCoreContrib
18+
uses: actions/checkout@v6
19+
with:
20+
repository: OrchardCoreContrib/OrchardCoreContrib
21+
submodules: true
22+
token: ${{ secrets.OCC_TOKEN }}
23+
24+
- name: Capture Current Submodule Commit Hash
25+
id: submodule-old
26+
shell: pwsh
27+
run: |
28+
$line = (git submodule status --recursive | Select-Object -First 1).Trim()
29+
$parts = $line -split '\s+'
30+
$hash = $parts[0].TrimStart('-','+')
31+
$path = $parts[1]
32+
"hash=$hash" >> $env:GITHUB_OUTPUT
33+
"path=$path" >> $env:GITHUB_OUTPUT
34+
35+
- name: Update submodule
36+
run: |
37+
git submodule sync --recursive
38+
git submodule update --init --recursive
39+
git submodule update --recursive --remote
40+
41+
- name: Capture Updated Submodule Details
42+
id: submodule-new
43+
shell: pwsh
44+
env:
45+
OLD_HASH: ${{ steps.submodule-old.outputs.hash }}
46+
SUBMODULE_PATH: ${{ steps.submodule-old.outputs.path }}
47+
run: |
48+
$line = (git submodule status --recursive | Select-Object -First 1).Trim()
49+
$newHash = ($line -split '\s+')[0].TrimStart('-','+')
50+
51+
$repoUrl = (git -C $env:SUBMODULE_PATH config --get remote.origin.url).Trim()
52+
if ($repoUrl -match '^git@github\.com:(.+)\.git$') {
53+
$repoUrl = "https://github.com/$($Matches[1])"
54+
} else {
55+
$repoUrl = $repoUrl -replace '\.git$',''
56+
}
57+
58+
$repoName = $repoUrl.Split('/')[-1]
59+
$oldShort = $env:OLD_HASH.Substring(0,7)
60+
$newShort = $newHash.Substring(0,7)
61+
62+
"repoUrl=$repoUrl" >> $env:GITHUB_OUTPUT
63+
"repoName=$repoName" >> $env:GITHUB_OUTPUT
64+
"oldHash=$($env:OLD_HASH)" >> $env:GITHUB_OUTPUT
65+
"newHash=$newHash" >> $env:GITHUB_OUTPUT
66+
"oldShort=$oldShort" >> $env:GITHUB_OUTPUT
67+
"newShort=$newShort" >> $env:GITHUB_OUTPUT
68+
"oldCommitUrl=$repoUrl/commit/$($env:OLD_HASH)" >> $env:GITHUB_OUTPUT
69+
"newCommitUrl=$repoUrl/commit/$newHash" >> $env:GITHUB_OUTPUT
70+
"compareUrl=$repoUrl/compare/$($env:OLD_HASH)...$newHash" >> $env:GITHUB_OUTPUT
71+
72+
- name: Create Pull Request
73+
uses: peter-evans/create-pull-request@v7
74+
with:
75+
token: ${{ secrets.OCC_TOKEN }}
76+
commit-message: Update submodule to latest version
77+
title: Update OrchardCoreContrib.Testing Submodule Version
78+
body: |
79+
Updated [${{ steps.submodule-new.outputs.repoName }}](${{ steps.submodule-new.outputs.repoUrl }}) from ${{ steps.submodule-new.outputs.oldShort }} to ${{ steps.submodule-new.outputs.newShort }}.
80+
81+
<details>
82+
<summary>Details</summary>
83+
84+
_This automated submodule update was generated by workflow._
85+
86+
- Old commit: [${{ steps.submodule-new.outputs.oldShort }}](${{ steps.submodule-new.outputs.oldCommitUrl }})
87+
- New commit: [${{ steps.submodule-new.outputs.newShort }}](${{ steps.submodule-new.outputs.newCommitUrl }})
88+
89+
[View changes](${{ steps.submodule-new.outputs.compareUrl }})
90+
</details>
91+
branch: update-submodule
92+
delete-branch: true
93+
base: main
94+
labels: |
95+
dependencies
96+
submodule

0 commit comments

Comments
 (0)