Skip to content

Commit

Permalink
feat: Able to set upstream and origin branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lcenchew committed Aug 16, 2020
1 parent 175997d commit 814b20b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Merge changes from an upstream repository branch into a current repository branc

Current limitations:
- only merge only selected branch
- branch has to be of the same name
- only work with public upstream Github repository
- merge fast forward only (--ff-only)

## Usage

Expand All @@ -20,10 +20,14 @@ on:
description: 'Upstream repository owner/name. Eg. exions/merge-upstream'
required: true
default: 'owner/name' # set the upstream repo
upstream:
description: 'Upstream branch to merge from. Eg. master'
required: true
default: 'master' # set the upstream branch to merge from
branch:
description: 'Branch to merge'
description: 'Branch to merge to'
required: true
default: 'master' # set the branch to merge
default: 'upstream' # set the branch to merge to

jobs:
merge-upstream:
Expand All @@ -38,6 +42,7 @@ jobs:
uses: exions/merge-upstream@v1
with:
upstream: ${{ github.event.inputs.upstream }}
upstream-branch: ${{ github.event.inputs.upstream-branch }}
branch: ${{ github.event.inputs.branch }}
```
Expand All @@ -57,17 +62,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
with:
ref: master # set the branch to merge
ref: upstream # set the branch to merge to
fetch-depth: 0
- name: Merge Upstream
uses: exions/merge-upstream@v1
with:
upstream: owner/repo # set the upstream repo
branch: master # set the branch to merge
upstream: owner/repo # set the upstream repo
upstream-branch: master # set the upstream branch to merge from
branch: upstream # set the branch to merge to
```
Reference:
- [Triggering a workflow with events](https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#triggering-a-workflow-with-events)
- [Creating a composite run steps action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action)
## How to run this action manually
Expand All @@ -76,6 +83,6 @@ This action can trigger manually as needed.
1. Go to `Actions` at the top of your Github repository
2. Click on `Manual Merge Upstream Action` (or other name you have given) under `All workflows`
3. You will see `Run workflow`, click on it
4. Fill in the upstream repository and the branch to merge (⚠️ make sure it is correct)
4. Fill in the upstream repository and branch to merge from, and the branch to merge to (⚠️ double check all are correct)
5. Click `Run workflow`
6. Check your branch commit history
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ inputs:
upstream:
description: 'Upstream repository owner/name. For example, exions/merge-upstream'
required: true
upstream-branch:
description: 'Upstream branch to merge from. For example, master'
default: 'master'
branch:
description: 'Branch to merge to. For example, master'
default: 'master'
Expand All @@ -18,6 +21,9 @@ runs:
steps:
- run: |
git remote add -f upstream "https://github.com/${{ inputs.upstream }}.git"
git merge --ff-only upstream/${{ inputs.branch }}
git remote -v
git branch --all
git checkout ${{ inputs.branch }}
git merge --ff-only upstream/${{ inputs.upstream-branch }}
git push
shell: bash

0 comments on commit 814b20b

Please sign in to comment.