generated from frutbits/template
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (40 loc) · 1.6 KB
/
update-submodules.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
name: Update Git Submodules
on:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
jobs:
SubmoduleSync:
runs-on: ubuntu-latest
steps:
- name: Update any submodules
run: |
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
echo -e "\n# Checkout the repo in the target branch"
TARGET_BRANCH="main"
git clone --recurse-submodules -j8 -b $TARGET_BRANCH $REPO sapphiredev-website
echo -e "\n# Moving to newly cloned repository"
cd sapphiredev-website
echo -e "\n# Updating submodules"
git pull --recurse-submodules && git submodule update --remote --recursive
echo -e "\n# Add all files in current directory"
git add --all .
if git diff-index --quiet HEAD --; then
echo "No changes to commit, exiting with code 0"
exit 0;
else
echo -e "\n# Before pushing changes we update the lockfile"
echo -e "\nenableImmutableInstalls: false" >> ./.yarnrc.yml
rm -rf ./node_modules ./yarn.lock || true
yarn install
echo -e "\n# Adding yarn lockfile"
git add yarn.lock
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_EMAIL}"
git commit -snm "chore: updated GitHub Submodules at $(date '+%F %H:%M.%S')" || true
git push origin $TARGET_BRANCH
fi
env:
GITHUB_TOKEN: ${{ secrets.ZHYCORP_TOKEN }}
GITHUB_ACTOR: zhycorpdev-bot
GITHUB_EMAIL: [email protected]