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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.0

- Add input from_branch, perform a git merge for any branch combination.

## v1.1.1

- Validate inputs
Expand Down
79 changes: 59 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,90 @@
## Merge branch action

### On labeled
Runs a git merge in your CI.

Merge pull request branch using GitHub labels.
Examples:

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.

![PR](./screenshots/pr.png)
![Checker](./screenshots/checker.png)
### Sync branches

```yaml
name: Merge branch
name: Sync multiple branches
on:
pull_request:
types: [labeled]
push:
branches:
- '*'
jobs:
merge-branch:
sync-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge by labeled
uses: devmasx/merge-branch@v1.1.0

- name: Merge development -> staging
uses: devmasx/merge-branch@v1.2.0
with:
label_name: 'merged in develop'
target_branch: 'develop'
type: now
from_branch: development
target_branch: staging
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Merge staging -> uat
uses: devmasx/merge-branch@v1.2.0
with:
type: now
from_branch: staging
target_branch: uat
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```

## On any GitHub event
### Merge current branch

```yaml
name: Merge staging branch to uat
name: Merge any release branch to uat
on:
push:
branches:
- 'staging'
- 'release/*'
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge to uat branch
uses: devmasx/merge-branch@v1.1.0

- name: Merge staging -> uat
uses: devmasx/merge-branch@v1.2.0
with:
type: now
target_branch: 'uat'
target_branch: uat
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```

### On labeled

Merge pull request branch using GitHub labels.

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.

![PR](./screenshots/pr.png)
![Checker](./screenshots/checker.png)

```yaml
name: Merge branch with labeled
on:
pull_request:
types: [labeled]
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Merge by labeled
uses: devmasx/merge-branch@v1.2.0
with:
label_name: 'merged in develop'
target_branch: 'develop'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ inputs:
target_branch:
description: 'The name of target branch to merge'
required: true
from_branch:
description: 'Alias head_to_merge input'
required: false
head_to_merge:
description: 'The branch name or hash to merge. default GITHUB_SHA'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
2 changes: 1 addition & 1 deletion lib/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative './services/merge_branch_service'

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

Expand Down