Skip to content

Update Git Submodules #467

Update Git Submodules

Update Git Submodules #467

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]