Skip to content

Commit c63fc01

Browse files
author
Prakash Surya
authored
Sync "6.0/stage" with "master" via GitHub Actions (#211)
1 parent 7e38088 commit c63fc01

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.github/scripts/install-hub.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -eux
2+
3+
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s v2.14.2
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash -eux
2+
3+
#
4+
# This variable must be passed into this script.
5+
#
6+
[[ -n "${BRANCH}" ]] || exit 1
7+
8+
#
9+
# We need these config parameters set in order to do the git-merge.
10+
#
11+
git config user.name "${GITHUB_ACTOR}"
12+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
13+
14+
#
15+
# We need the full git repository history in order to do the git-merge.
16+
#
17+
git fetch --unshallow
18+
19+
#
20+
# In order to open a pull request, we need to push to a remote branch.
21+
# To avoid conflicting with existing remote branches, we use branches
22+
# within the "sync-with-master" namespace.
23+
#
24+
git checkout -b "sync-with-master/${BRANCH}" "origin/${BRANCH}"
25+
git merge -Xtheirs origin/master
26+
git push -f origin "sync-with-master/${BRANCH}"
27+
28+
#
29+
# Opening a pull request may fail if there already exists a pull request
30+
# for the branch; e.g. if a previous pull request was previously made,
31+
# but not yet merged by the time we run this "sync" script again. Thus,
32+
# rather than causing the automation to report a failure in this case,
33+
# we swallow the error and report success.
34+
#
35+
# Additionally, as along as the git branch was properly updated (via the
36+
# "git push" above), the existing PR will have been updated as well, so
37+
# the "hub" command is unnecessary (hence ignoring the error).
38+
#
39+
git log -1 --format=%B | hub pull-request -F - -b "${BRANCH}" || true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
sync:
10+
strategy:
11+
matrix:
12+
branch:
13+
- 6.0/stage
14+
runs-on: ubuntu-18.04
15+
steps:
16+
- uses: actions/checkout@v2
17+
- run: ./.github/scripts/install-hub.sh
18+
- run: ./.github/scripts/sync-with-master.sh
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
BRANCH: ${{ matrix.branch }}

0 commit comments

Comments
 (0)