|
# Copyright 2019 The IREE Authors |
|
# |
|
# Licensed under the Apache License v2.0 with LLVM Exceptions. |
|
# See https://llvm.org/LICENSE.txt for license information. |
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
|
|
|
# Edits the HEAD commit if it is tagged with the Copybara tag to use the |
|
# submodule state specified in SUBMODULE_VERSIONS.txt and merge from the |
|
# specified commit. |
|
# WARNING: rewrites history! |
|
|
|
name: Fixup Copybara |
|
|
|
on: |
|
push: |
|
branches: |
|
# Do not add this to human branches like main. It rewrites history! |
|
- google |
|
|
|
env: |
|
COPYBARA_TAG: "COPYBARA_INTEGRATE_REVIEW" |
|
UPSTREAM_REMOTE: origin |
|
|
|
jobs: |
|
fixup: |
|
runs-on: ubuntu-18.04 |
|
# Don't run this in everyone's forks. |
|
if: github.repository == 'google/iree' |
|
steps: |
|
- name: Checking out repository |
|
uses: actions/checkout@v2 |
|
with: |
|
token: ${{ secrets.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: Setting git config |
|
run: | |
|
git config --local user.email "iree-github-actions-bot@google.com" |
|
git config --local user.name "Copybara Fixup Action" |
|
- name: Running fixer script |
|
run: | |
|
./scripts/git/fix_copybara_export.sh |
|
- name: Checking for a change |
|
run: | |
|
echo "commit_amended=false" >> $GITHUB_ENV |
|
if [[ "$(git rev-parse HEAD)" != "${GITHUB_SHA?}" ]]; then |
|
echo "commit_amended=true" >> $GITHUB_ENV |
|
fi |
|
- name: Pushing changes |
|
if: env.commit_amended == 'true' |
|
run: git push -f origin ${{ github.ref }} |
|
|
|
check_submodules: |
|
runs-on: ubuntu-18.04 |
|
steps: |
|
- name: Checking out repository |
|
uses: actions/checkout@v2 |
|
- name: Checking submodules |
|
run: ./scripts/git/submodule_versions.py check |
|
|
|
check_copybara_tag: |
|
runs-on: ubuntu-18.04 |
|
steps: |
|
- name: Checking out repository |
|
uses: actions/checkout@v2 |
|
- name: Checking for Copybara tag |
|
run: | |
|
if git log --format=%B -n 1 HEAD | grep -q "${COPYBARA_TAG}"; then |
|
echo "Commit contains Copybara tag" |
|
exit 1 |
|
fi |