-
Notifications
You must be signed in to change notification settings - Fork 22
56 lines (45 loc) · 1.42 KB
/
submodule_sync.yml
File metadata and controls
56 lines (45 loc) · 1.42 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
name: submodules-sync
on:
push:
branches: ['**']
tags: ['v*.*.*']
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
name: 'Submodules Sync'
runs-on: ubuntu-latest
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ github.token }}
submodules: recursive
fetch-depth: 0
- name: Sync submodules using repository script
id: sync_submodules
run: |
set -euo pipefail
before_sha="$(git rev-parse HEAD)"
# script may create a commit when submodule pointers change
git config user.name "Git bot"
git config user.email "bot@noreply.github.com"
./scripts/git_update_submodules_in_repo.sh
after_sha="$(git rev-parse HEAD)"
if [ "$before_sha" != "$after_sha" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
git show --no-patch --oneline "$after_sha"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No submodule pointer changes."
fi
- name: Push sync commit
if: startsWith(github.ref, 'refs/heads/') && steps.sync_submodules.outputs.changed == 'true'
run: git push origin HEAD:${GITHUB_REF##refs/heads/}