Skip to content

Commit 3e8a67f

Browse files
track the xgovforms changes (#107)
track the xgovforms changes track the xgovforms changes track the xgovforms changes track the xgovforms changes track the xgovforms changes track the xgovforms changes
1 parent 24de74a commit 3e8a67f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Update Submodule Automatically
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * *' # Run daily at 3:00 AM UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
update-submodule:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Step 1: Check out the repository with submodules
14+
- name: Checkout repository with submodules
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: true
18+
fetch-depth: 0
19+
20+
# Step 2: Update all submodules to their latest commits
21+
- name: Update submodules with latest changes
22+
run: |
23+
git submodule update --remote --merge
24+
if [ -n "$(git status --porcelain)" ]; then
25+
echo "Updating the submodule XGovFormBuilder to latest."
26+
echo "submodule_updated=true" >> $GITHUB_ENV
27+
else
28+
echo "No updates found in submodules."
29+
echo "submodule_updated=false" >> $GITHUB_ENV
30+
fi
31+
32+
# Step 3: Extract the latest submodule commit hash (first 7 characters)
33+
- name: Get submodule commit hash
34+
if: env.submodule_updated == 'true' # Run only if submodule was updated
35+
id: submodule_hash
36+
run: |
37+
# Extract the first 7 characters of the latest submodule commit
38+
SUBMODULE_PATH=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
39+
SUBMODULE_COMMIT=$(git rev-parse --short=7 HEAD:$SUBMODULE_PATH)
40+
echo "submodule_hash=${SUBMODULE_COMMIT}" >> $GITHUB_ENV
41+
42+
# Step 4: Create a pull request with the dynamic branch name
43+
- name: Create a pull request about the updates happen
44+
if: env.submodule_updated == 'true'
45+
uses: peter-evans/create-pull-request@v5
46+
with:
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
branch: "XGovFormBuilder-${{ env.submodule_hash }}"
49+
base: main
50+
title: "Updating the submodule XGovFormBuilder to latest"
51+
body: |
52+
Following Pr will contain the update that need to be done against the [XGovFormBuilder](https://github.com/XGovFormBuilder/digital-form-builder)
53+
for the submodule
54+
55+
Submodule updated to commit hash: `${{ env.submodule_hash }}`
56+
57+
Please Do manual testing before merge.

0 commit comments

Comments
 (0)