| # 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. |
| |
| # Edits the HEAD commit to use the submodule state specified in SUBMODULE_VERSIONS.txt |
| # WARNING: rewrites history! |
| |
| name: Synchronize Submodules |
| |
| on: |
| push: |
| branches: |
| # Do not add this to human branches like main. It rewrites history! |
| - google |
| |
| jobs: |
| synchronize: |
| runs-on: ubuntu-18.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@v2 |
| with: |
| token: ${{ secrets.GITHUB_WRITE_ACCESS_TOKEN }} |
| # Get all history. We're force-pushing here and will otherwise drop |
| # all the branch history. This takes a whopping 2 seconds. I think |
| # we'll live. |
| fetch-depth: 0 |
| - name: Importing submodules from SUBMODULE_VERSIONS.txt |
| run: ./scripts/git/submodule_versions.py import |
| - name: Checking submodule state |
| run: | |
| echo "has_diff=false" >> $GITHUB_ENV |
| git diff --cached --exit-code || echo "has_diff=true" >> $GITHUB_ENV |
| - name: Committing updates |
| if: env.has_diff == 'true' |
| run: | |
| git config --local user.email "iree-github-actions-bot@google.com" |
| git config --local user.name "Submodule Synchronize Action" |
| git commit --amend -a --no-edit |
| - name: Pushing changes |
| if: env.has_diff == 'true' |
| run: git push -f origin ${{ github.ref }} |
| |
| check: |
| runs-on: ubuntu-18.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@v2 |
| - name: Checking submodules |
| run: ./scripts/git/submodule_versions.py check |