-
Notifications
You must be signed in to change notification settings - Fork 42
85 lines (75 loc) · 3.05 KB
/
Copy pathsubmodule-sync.yml
File metadata and controls
85 lines (75 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Submodule Sync
on:
repository_dispatch:
types: [loong-megatron-submodule-updated]
workflow_dispatch:
inputs:
target_branch:
description: Branch to update in this repository
required: true
default: master
submodule_path:
description: Submodule path to update
required: true
default: third_party/Loong-Megatron
submodule_branch:
description: Submodule branch to track
required: true
default: loong-main/core_v0.15.0
submodule_repository:
description: Optional owner/repo override for fork validation
required: false
default: ''
permissions:
contents: write
concurrency:
group: submodule-sync-${{ github.event.inputs.target_branch || github.event.client_payload.target_branch || 'master' }}
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event.inputs.target_branch || github.event.client_payload.target_branch || 'master' }}
SUBMODULE_PATH: ${{ github.event.inputs.submodule_path || github.event.client_payload.submodule_path || 'third_party/Loong-Megatron' }}
SUBMODULE_BRANCH: ${{ github.event.inputs.submodule_branch || github.event.client_payload.submodule_branch || 'loong-main/core_v0.15.0' }}
SUBMODULE_REPOSITORY: ${{ github.event.inputs.submodule_repository || github.event.client_payload.submodule_repository || '' }}
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
token: ${{ github.token }}
fetch-depth: 0
submodules: false
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Update submodule pointer
id: update
shell: bash
run: |
set -euo pipefail
git submodule sync -- "$SUBMODULE_PATH"
if [ -n "$SUBMODULE_REPOSITORY" ]; then
git config "submodule.$SUBMODULE_PATH.url" "https://github.com/$SUBMODULE_REPOSITORY.git"
fi
git submodule update --init -- "$SUBMODULE_PATH"
git -C "$SUBMODULE_PATH" fetch origin "$SUBMODULE_BRANCH"
git submodule update --remote -- "$SUBMODULE_PATH"
if git diff --quiet -- "$SUBMODULE_PATH"; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Submodule $SUBMODULE_PATH is already current on $SUBMODULE_BRANCH."
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "New submodule pointer:"
git diff --submodule=log -- "$SUBMODULE_PATH"
- name: Commit submodule update
if: steps.update.outputs.changed == 'true'
run: |
git add "$SUBMODULE_PATH"
git commit -m "[ci] chore: sync Loong-Megatron submodule"
- name: Push submodule update
if: steps.update.outputs.changed == 'true'
run: git push origin "HEAD:$TARGET_BRANCH"