-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (38 loc) · 1.64 KB
/
submodule-sync.yaml
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
# Adapted from https://stackoverflow.com/questions/64407333/using-github-actions-to-automatically-update-the-repos-submodules
name: 'Submodules sync'
on:
# Allows you to run this workflow manually from the Actions tab or through HTTP API
workflow_dispatch:
# We need to run this periodically as well, because we don't want to fork every upstream in order to
# keep them up to date in my use of them. Once per day should be good enough for release cycle and
# security patch purposes
schedule:
- cron: "0 0 * * *"
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/[email protected]
with:
token: ${{ secrets.PAT_TOKEN }}
submodules: recursive
# Update references
- name: Git submodule update
run: |
git submodule foreach 'git fetch --unshallow'
git submodule foreach 'git pull origin $(git config -f $GITHUB_WORKSPACE/.gitmodules --get submodule.$name.branch)'
- name: Commit update to submodule-updates for PR
env:
PAT_GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
git config --global user.name 'Git Bot'
git config --global user.email '[email protected]'
git fetch --unshallow
git remote set-url origin https://[email protected]/$GITHUB_REPOSITORY
git commit -am "Updated all submodule references" && git push -f origin HEAD:refs/heads/automerge/submodule-updates || echo "No changes to commit"