-
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·46 lines (39 loc) · 1.35 KB
/
submodule-update.yml
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
name: Submodule update
on:
schedule:
- cron: '0 6 * * MON'
workflow_dispatch:
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodule
uses: actions/checkout@v2
with:
submodules: recursive
- name: script
run: |
cd learnGitBranching
if [ $(git rev-list HEAD...origin/main --count) != 0 ]; then
echo 'Update pending'
echo "REPO_DISPATCH=true" >> "$GITHUB_ENV"
else
echo 'Nothing to update'
echo "REPO_DISPATCH=false" >> "$GITHUB_ENV"
exit 0
fi
cd ..
msg=$(git submodule update --remote)
commitstr=$(echo $msg | grep -oP "checked out '\K\w+")
git config --global user.name 'Git bot'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Auto updated submodule reference: pcottle/learnGitBranching@${commitstr}"
git push
- name: Repository Dispatch
if: env.REPO_DISPATCH != 'false'
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: ${{ github.repository }}
event-type: submodule-updated