Skip to content

Commit 814b20b

Browse files
committed
feat: Able to set upstream and origin branch
1 parent 175997d commit 814b20b

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Merge changes from an upstream repository branch into a current repository branc
33

44
Current limitations:
55
- only merge only selected branch
6-
- branch has to be of the same name
76
- only work with public upstream Github repository
7+
- merge fast forward only (--ff-only)
88

99
## Usage
1010

@@ -20,10 +20,14 @@ on:
2020
description: 'Upstream repository owner/name. Eg. exions/merge-upstream'
2121
required: true
2222
default: 'owner/name' # set the upstream repo
23+
upstream:
24+
description: 'Upstream branch to merge from. Eg. master'
25+
required: true
26+
default: 'master' # set the upstream branch to merge from
2327
branch:
24-
description: 'Branch to merge'
28+
description: 'Branch to merge to'
2529
required: true
26-
default: 'master' # set the branch to merge
30+
default: 'upstream' # set the branch to merge to
2731

2832
jobs:
2933
merge-upstream:
@@ -38,6 +42,7 @@ jobs:
3842
uses: exions/merge-upstream@v1
3943
with:
4044
upstream: ${{ github.event.inputs.upstream }}
45+
upstream-branch: ${{ github.event.inputs.upstream-branch }}
4146
branch: ${{ github.event.inputs.branch }}
4247
```
4348
@@ -57,17 +62,19 @@ jobs:
5762
- name: Checkout
5863
uses: actions/checkout@v2
5964
with:
60-
ref: master # set the branch to merge
65+
ref: upstream # set the branch to merge to
6166
fetch-depth: 0
6267
- name: Merge Upstream
6368
uses: exions/merge-upstream@v1
6469
with:
65-
upstream: owner/repo # set the upstream repo
66-
branch: master # set the branch to merge
70+
upstream: owner/repo # set the upstream repo
71+
upstream-branch: master # set the upstream branch to merge from
72+
branch: upstream # set the branch to merge to
6773
```
6874
6975
Reference:
7076
- [Triggering a workflow with events](https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#triggering-a-workflow-with-events)
77+
- [Creating a composite run steps action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action)
7178
7279
## How to run this action manually
7380
@@ -76,6 +83,6 @@ This action can trigger manually as needed.
7683
1. Go to `Actions` at the top of your Github repository
7784
2. Click on `Manual Merge Upstream Action` (or other name you have given) under `All workflows`
7885
3. You will see `Run workflow`, click on it
79-
4. Fill in the upstream repository and the branch to merge (⚠️ make sure it is correct)
86+
4. Fill in the upstream repository and branch to merge from, and the branch to merge to (⚠️ double check all are correct)
8087
5. Click `Run workflow`
8188
6. Check your branch commit history

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ inputs:
99
upstream:
1010
description: 'Upstream repository owner/name. For example, exions/merge-upstream'
1111
required: true
12+
upstream-branch:
13+
description: 'Upstream branch to merge from. For example, master'
14+
default: 'master'
1215
branch:
1316
description: 'Branch to merge to. For example, master'
1417
default: 'master'
@@ -18,6 +21,9 @@ runs:
1821
steps:
1922
- run: |
2023
git remote add -f upstream "https://github.com/${{ inputs.upstream }}.git"
21-
git merge --ff-only upstream/${{ inputs.branch }}
24+
git remote -v
25+
git branch --all
26+
git checkout ${{ inputs.branch }}
27+
git merge --ff-only upstream/${{ inputs.upstream-branch }}
2228
git push
2329
shell: bash

0 commit comments

Comments
 (0)