diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e97f7..d9ecb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.2.0 + +- Add input from_branch, perform a git merge for any branch combination. + ## v1.1.1 - Validate inputs diff --git a/README.md b/README.md index e92fcdb..5e687ed 100644 --- a/README.md +++ b/README.md @@ -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}} ``` diff --git a/action.yml b/action.yml index 0428b38..f2beea4 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/lib/index.rb b/lib/index.rb index 135224e..7e4701e 100644 --- a/lib/index.rb +++ b/lib/index.rb @@ -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']