blob: 21db080bc39513969df5e5c2bdd9817751ef1e83 [file] [log] [blame]
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Sets submodule state to the one specified in SUBMODULE_VERSIONS
name: Synchronize Submodules
on:
push:
branches:
- master
jobs:
synchronize:
runs-on: ubuntu-18.04
steps:
- name: Checking out repository
uses: actions/checkout@v2
- name: Initializing submodules
run: ./scripts/git/submodule_versions.py init
- name: Checking submodule state
run: |
echo "::set-env name=has_diff::false"
git diff --cached --exit-code || echo "::set-env name=has_diff::true"
- name: Committing updates
if: env.has_diff == 'true'
run: |
git config --local user.email "noreply+action@github.com"
git config --local user.name "Submodule Synchronize Action"
git commit -am "Synchronize submodules"
- name: Pushing changes
if: env.has_diff == 'true'
# Will push regardless, but exit successfully if already up to date with master
uses: ad-m/github-push-action@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}