Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/install-hub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -eux

curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s v2.14.2
39 changes: 39 additions & 0 deletions .github/scripts/sync-with-master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash -eux

#
# This variable must be passed into this script.
#
[[ -n "${BRANCH}" ]] || exit 1

#
# We need these config parameters set in order to do the git-merge.
#
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

#
# We need the full git repository history in order to do the git-merge.
#
git fetch --unshallow

#
# In order to open a pull request, we need to push to a remote branch.
# To avoid conflicting with existing remote branches, we use branches
# within the "sync-with-master" namespace.
#
git checkout -b "sync-with-master/${BRANCH}" "origin/${BRANCH}"
git merge -Xtheirs origin/master
git push -f origin "sync-with-master/${BRANCH}"

#
# Opening a pull request may fail if there already exists a pull request
# for the branch; e.g. if a previous pull request was previously made,
# but not yet merged by the time we run this "sync" script again. Thus,
# rather than causing the automation to report a failure in this case,
# we swallow the error and report success.
#
# Additionally, as along as the git branch was properly updated (via the
# "git push" above), the existing PR will have been updated as well, so
# the "hub" command is unnecessary (hence ignoring the error).
#
git log -1 --format=%B | hub pull-request -F - -b "${BRANCH}" || true
21 changes: 21 additions & 0 deletions .github/workflows/sync-with-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * *'

jobs:
sync:
strategy:
matrix:
branch:
- 6.0/stage
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: ./.github/scripts/install-hub.sh
- run: ./.github/scripts/sync-with-master.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ matrix.branch }}