Merge pull request #14413 from daschuer/AbstractLegacyControllerSetting #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Branches | |
on: | |
push: | |
branches: | |
- "2.4" | |
- "2.5" | |
workflow_dispatch: | |
permissions: {} | |
jobs: | |
sync-branches: | |
strategy: | |
matrix: | |
include: | |
- from_branch: "2.4" | |
to_branch: "2.5" | |
- from_branch: "2.5" | |
to_branch: "main" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
SYNC_COMMITTER: github-actions[bot] | |
steps: | |
- name: "Check out repository" | |
uses: actions/checkout@v4.1.7 | |
with: | |
persist-credentials: true | |
- name: "Configure Git" | |
run: | | |
git config --global merge.ours.driver true | |
git config --global pull.rebase false | |
- name: "Check if merge branch already exists" | |
id: check_sync | |
run: | | |
if git fetch origin "${SYNC_BRANCH}"; then | |
echo "Branch ${SYNC_BRANCH} already exists, checking if the branch was modified..." | |
COMMITTER="$(git show --pretty=format:"%cn <%ce>" --no-patch "origin/${SYNC_BRANCH}")" | |
if [ "${COMMITTER}" = "${SYNC_COMMITTER}" ]; then | |
echo "Branch ${SYNC_BRANCH} was not modified." | |
else | |
echo "Branch ${SYNC_BRANCH} was modified, either delete it or update it yourself." | |
echo "skip_sync=true" >> $GITHUB_OUTPUT | |
fi | |
else | |
echo "Branch ${SYNC_BRANCH} does not exist yet." | |
fi | |
env: | |
SYNC_BRANCH: sync-branch-${{ matrix.from_branch}}-to-${{ matrix.to_branch }} | |
- name: "Merge Changes" | |
if: steps.check_sync.outputs.skip_sync != 'true' | |
run: | | |
git checkout -b "${SYNC_BRANCH}" | |
git fetch origin "${TO_BRANCH}" | |
git reset --hard "origin/${TO_BRANCH}" | |
git pull --no-edit origin "${FROM_BRANCH}" | |
COMMIT_ORIGINAL="$(git show --no-patch --format="%h" "origin/${TO_BRANCH}")" | |
COMMIT_MERGE="$(git show --no-patch --format="%h" "origin/${TO_BRANCH}")" | |
if [ "${COMMIT_ORIGINAL}" = "${COMMIT_MERGE}" ]; then | |
git status | |
echo "No changes (or merge conflict), skipping push and PR creation." | |
else | |
git push --force origin "${SYNC_BRANCH}" | |
gh pr create -B "${FROM_BRANCH}" -H "${SYNC_BRANCH}" --title "${PULL_REQUEST_TITLE}" --body "${PULL_REQUEST_BODY}" --labels "sync-branches" | |
fi | |
env: | |
FROM_BRANCH: ${{ matrix.from_branch}} | |
TO_BRANCH: ${{ matrix.to_branch }} | |
SYNC_BRANCH: sync-branch-${{ matrix.from_branch}}-to-${{ matrix.to_branch }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PULL_REQUEST_TITLE: Merge changes from `${{ matrix.from_branch }}` into `${{ matrix.to_branch }}` | |
PULL_REQUEST_BODY: | | |
New content has landed in the `${{ matrix.from_branch }}` branch, so let's merge the changes into `${{ matrix.to_branch }}`. |