Skip to content

Commit 2cba488

Browse files
Add optional input from_branch (#4)
* Add optional set HEAD_TO_MERGE * New example merge any release branch * update CHANGELOG * update README
1 parent 3d828f9 commit 2cba488

File tree

4 files changed

+70
-21
lines changed

4 files changed

+70
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.2.0
2+
3+
- Add input from_branch, perform a git merge for any branch combination.
4+
15
## v1.1.1
26

37
- Validate inputs

README.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,90 @@
11
## Merge branch action
22

3-
### On labeled
3+
Runs a git merge in your CI.
44

5-
Merge pull request branch using GitHub labels.
5+
Examples:
66

7-
When you set a label in a pull request this action can merge the pull request branch to other branch, useful for develop branch or staging environments.
8-
9-
![PR](./screenshots/pr.png)
10-
![Checker](./screenshots/checker.png)
7+
### Sync branches
118

129
```yaml
13-
name: Merge branch
10+
name: Sync multiple branches
1411
on:
15-
pull_request:
16-
types: [labeled]
12+
push:
13+
branches:
14+
- '*'
1715
jobs:
18-
merge-branch:
16+
sync-branch:
1917
runs-on: ubuntu-latest
2018
steps:
2119
- uses: actions/checkout@master
22-
- name: Merge by labeled
23-
uses: devmasx/[email protected]
20+
21+
- name: Merge development -> staging
22+
uses: devmasx/[email protected]
2423
with:
25-
label_name: 'merged in develop'
26-
target_branch: 'develop'
24+
type: now
25+
from_branch: development
26+
target_branch: staging
27+
env:
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
30+
- name: Merge staging -> uat
31+
uses: devmasx/[email protected]
32+
with:
33+
type: now
34+
from_branch: staging
35+
target_branch: uat
2736
env:
2837
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2938
```
3039
31-
## On any GitHub event
40+
### Merge current branch
3241
3342
```yaml
34-
name: Merge staging branch to uat
43+
name: Merge any release branch to uat
3544
on:
3645
push:
3746
branches:
38-
- 'staging'
47+
- 'release/*'
3948
jobs:
4049
merge-branch:
4150
runs-on: ubuntu-latest
4251
steps:
4352
- uses: actions/checkout@master
44-
- name: Merge to uat branch
45-
uses: devmasx/[email protected]
53+
54+
- name: Merge staging -> uat
55+
uses: devmasx/[email protected]
4656
with:
4757
type: now
48-
target_branch: 'uat'
58+
target_branch: uat
59+
env:
60+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
61+
```
62+
63+
### On labeled
64+
65+
Merge pull request branch using GitHub labels.
66+
67+
When you set a label in a pull request this action can merge the pull request branch to other branch, useful for develop branch or staging environments.
68+
69+
![PR](./screenshots/pr.png)
70+
![Checker](./screenshots/checker.png)
71+
72+
```yaml
73+
name: Merge branch with labeled
74+
on:
75+
pull_request:
76+
types: [labeled]
77+
jobs:
78+
merge-branch:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@master
82+
83+
- name: Merge by labeled
84+
uses: devmasx/[email protected]
85+
with:
86+
label_name: 'merged in develop'
87+
target_branch: 'develop'
4988
env:
5089
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
5190
```

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ inputs:
1212
target_branch:
1313
description: 'The name of target branch to merge'
1414
required: true
15+
from_branch:
16+
description: 'Alias head_to_merge input'
17+
required: false
18+
head_to_merge:
19+
description: 'The branch name or hash to merge. default GITHUB_SHA'
20+
required: false
1521
runs:
1622
using: 'docker'
1723
image: 'Dockerfile'

lib/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_relative './services/merge_branch_service'
44

55
@event = JSON.parse(File.read(ENV['GITHUB_EVENT_PATH']))
6-
@head_to_merge = ENV['GITHUB_SHA'] # or brach name
6+
@head_to_merge = ENV['INPUT_HEAD_TO_MERGE'] || ENV['INPUT_FROM_BRANCH'] || ENV['GITHUB_SHA'] # or brach name
77
@repository = ENV['GITHUB_REPOSITORY']
88
@github_token = ENV['GITHUB_TOKEN']
99

0 commit comments

Comments
 (0)