Skip to content

Commit f762884

Browse files
committed
[SIV] fix update submodule before creating a tag
1 parent ac08ce2 commit f762884

1 file changed

Lines changed: 40 additions & 7 deletions

File tree

.github/workflows/siv-weekly-tag.yaml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ name: "[SIV] Weekly Build Tagging"
22

33
on:
44
schedule:
5-
- cron: '0 15 * * 2' # Every Tuesday at 15:00 UTC
5+
- cron: '0 15 * * 2' # Every Tuesday at 15:00 UTC
66
workflow_dispatch:
77

8+
89
permissions: {}
910

1011
jobs:
1112
update-submodules-and-tag:
1213
runs-on: ubuntu-latest
1314
permissions:
1415
contents: write
16+
pull-requests: write
1517

1618
steps:
1719
- name: Checkout repository with submodules
@@ -102,20 +104,51 @@ jobs:
102104
echo "✅ Commit created: $COMMIT_SHA"
103105
echo "sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
104106
105-
- name: Push to current branch
107+
- name: Create PR and merge changes
106108
if: steps.submodule-status.outputs.has_changes == 'true'
107109
env:
108-
BRANCH_NAME: ${{ github.ref_name }}
110+
GH_TOKEN: ${{ secrets.SIV_USER_TOKEN_GH }}
111+
TARGET_BRANCH: ${{ github.ref_name }}
109112
run: |
110-
echo "🚀 Pushing changes to branch: $BRANCH_NAME"
111-
git push origin HEAD:$BRANCH_NAME
112-
echo "✅ Changes pushed successfully to $BRANCH_NAME"
113+
# Create a unique branch name for the PR
114+
PR_BRANCH="siv-auto-update-submodules-$(date +'%Y%m%d-%H%M%S')"
115+
echo "🌿 Creating branch: $PR_BRANCH"
116+
117+
# Push to the new branch
118+
git push origin HEAD:$PR_BRANCH
119+
echo "✅ Changes pushed to branch: $PR_BRANCH"
120+
121+
# Create the PR
122+
echo "📝 Creating Pull Request..."
123+
PR_URL=$(gh pr create \
124+
--base "$TARGET_BRANCH" \
125+
--head "$PR_BRANCH" \
126+
--title "[SIV] Auto-update submodules to latest commits" \
127+
--body "Automated weekly update of all submodules to their latest upstream commits.
128+
129+
Updated on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
130+
131+
This PR was automatically created by the weekly build workflow.")
132+
133+
echo "✅ PR created: $PR_URL"
134+
135+
# Merge the PR
136+
echo "🔀 Merging Pull Request..."
137+
gh pr merge "$PR_URL" --squash --delete-branch
138+
echo "✅ PR merged successfully"
139+
140+
# Fetch to get the merge commit
141+
git fetch origin "$TARGET_BRANCH"
113142
114143
- name: Get commit SHA for tagging
115144
id: get-sha
145+
env:
146+
TARGET_BRANCH: ${{ github.ref_name }}
116147
run: |
117148
if [ "${{ steps.submodule-status.outputs.has_changes }}" == "true" ]; then
118-
COMMIT_SHA="${{ steps.commit.outputs.sha }}"
149+
# Get the latest commit from the target branch after merge
150+
git fetch origin "$TARGET_BRANCH"
151+
COMMIT_SHA=$(git rev-parse origin/$TARGET_BRANCH)
119152
else
120153
# If no changes, get the current HEAD SHA
121154
COMMIT_SHA=$(git rev-parse HEAD)

0 commit comments

Comments
 (0)