From 33444cd94a9426510ddc686b10eb83042a461248 Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Sat, 18 Jul 2020 00:47:12 +0200 Subject: [PATCH 1/6] Add optiona set HEAD_TO_MERGE --- action.yml | 3 +++ lib/index.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 0428b38..01e6c08 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,9 @@ inputs: target_branch: description: 'The name of target branch to merge' required: true + 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..3d96259 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['GITHUB_SHA'] # or brach name @repository = ENV['GITHUB_REPOSITORY'] @github_token = ENV['GITHUB_TOKEN'] From 96c540dcc3de8efbe95c140cc52b2964902d5e2d Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Sat, 18 Jul 2020 01:34:14 +0200 Subject: [PATCH 2/6] Update README --- README.md | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e92fcdb..15f9aae 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@master - name: Merge by labeled - uses: devmasx/merge-branch@v1.1.0 + uses: devmasx/merge-branch@v1.2.0 with: label_name: 'merged in develop' target_branch: 'develop' @@ -41,11 +41,40 @@ jobs: 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}} +``` + +```yaml +name: Sync multiple branch +on: + push: + branches: + - '*' +jobs: + sync-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Merge development -> staging + uses: devmasx/merge-branch@v1.2.0 + with: + type: now + head_to_merge: development + target_branch: staging + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Merge staging -> uat + uses: devmasx/merge-branch@v1.2.0 + with: + type: now + head_to_merge: staging + target_branch: uat env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} ``` From d81268e0776d7df61541dee6ff099e31a7258d46 Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Sat, 18 Jul 2020 01:36:49 +0200 Subject: [PATCH 3/6] New example merge any release branch --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 15f9aae..5ecfc8d 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ jobs: ## On any GitHub event ```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 @@ -51,7 +51,7 @@ jobs: ``` ```yaml -name: Sync multiple branch +name: Sync multiple branches on: push: branches: From e683bfe952ad0d67d61513c00922b45a3aca227a Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Wed, 22 Jul 2020 16:54:09 +0200 Subject: [PATCH 4/6] update CHANGELOG --- CHANGELOG.md | 4 ++++ README.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e97f7..54aac7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.2.0 + +- Add input head_to_merge, perform a git merge for any branch combination. + ## v1.1.1 - Validate inputs diff --git a/README.md b/README.md index 5ecfc8d..eeb3057 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Merge by labeled uses: devmasx/merge-branch@v1.2.0 with: @@ -41,6 +42,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Merge staging -> uat uses: devmasx/merge-branch@v1.2.0 with: @@ -61,6 +63,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Merge development -> staging uses: devmasx/merge-branch@v1.2.0 with: @@ -69,6 +72,7 @@ jobs: target_branch: staging env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Merge staging -> uat uses: devmasx/merge-branch@v1.2.0 with: From 01aaafd046e196c659c5aeba3d4d217beffde84b Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Wed, 22 Jul 2020 17:07:04 +0200 Subject: [PATCH 5/6] update README --- README.md | 70 ++++++++++++++++++++++++++++------------------------ action.yml | 3 +++ lib/index.rb | 2 +- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index eeb3057..5e687ed 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,43 @@ ## Merge branch action -### On labeled - -Merge pull request branch using GitHub labels. +Runs a git merge in your CI. -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. +Examples: -![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 + - 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 any release branch to uat @@ -52,33 +60,31 @@ jobs: 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: Sync multiple branches +name: Merge branch with labeled on: - push: - branches: - - '*' + pull_request: + types: [labeled] jobs: - sync-branch: + merge-branch: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Merge development -> staging - uses: devmasx/merge-branch@v1.2.0 - with: - type: now - head_to_merge: development - target_branch: staging - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - - name: Merge staging -> uat + - name: Merge by labeled uses: devmasx/merge-branch@v1.2.0 with: - type: now - head_to_merge: staging - target_branch: uat + label_name: 'merged in develop' + target_branch: 'develop' env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} ``` diff --git a/action.yml b/action.yml index 01e6c08..f2beea4 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,9 @@ 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 diff --git a/lib/index.rb b/lib/index.rb index 3d96259..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['INPUT_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'] From 17060702d29aa6e06af2770ea766d0206ee8b652 Mon Sep 17 00:00:00 2001 From: Miguel Savignano Date: Wed, 22 Jul 2020 17:07:53 +0200 Subject: [PATCH 6/6] rename input name --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54aac7b..d9ecb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## v1.2.0 -- Add input head_to_merge, perform a git merge for any branch combination. +- Add input from_branch, perform a git merge for any branch combination. ## v1.1.1