-
Notifications
You must be signed in to change notification settings - Fork 14
62 lines (51 loc) · 2.28 KB
/
merge-master-to-develop.yml
File metadata and controls
62 lines (51 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Sync develop branch
on:
push:
branches:
# Keep this in sync with SYNC_SOURCE_BRANCH below.
# GitHub Actions does not allow env values in trigger branch filters.
- master
env:
SYNC_SOURCE_BRANCH: master
SYNC_TARGET_BRANCH: develop
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
sync-dev-branch:
name: Merge master into develop branch
# Keep this named after the GitHub repository.
# GitHub Actions does not allow workflow env values in jobs.<job_id>.if.
if: github.repository == 'phpbb-extensions/phpbb-ext-skeleton' && github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git author
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Merge source branch into target branch when clean
run: |
if ! git ls-remote --exit-code --heads origin "${SYNC_TARGET_BRANCH}" > /dev/null 2>&1; then
echo "origin/${SYNC_TARGET_BRANCH} does not exist; skipping."
exit 0
fi
git fetch --no-tags --prune origin "${SYNC_TARGET_BRANCH}"
git checkout -B "${SYNC_TARGET_BRANCH}" "origin/${SYNC_TARGET_BRANCH}"
if git merge --no-edit "$GITHUB_SHA"; then
if [ "$(git rev-list --count "origin/${SYNC_TARGET_BRANCH}..HEAD")" -eq 0 ]; then
echo "${SYNC_TARGET_BRANCH} is already up to date."
exit 0
fi
git push origin "HEAD:${SYNC_TARGET_BRANCH}"
else
echo "${SYNC_SOURCE_BRANCH} could not be merged cleanly into ${SYNC_TARGET_BRANCH}; skipping."
if git rev-parse -q --verify MERGE_HEAD > /dev/null; then
git merge --abort
fi
fi