Skip to content

Commit

Permalink
feat: Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lcenchew committed Aug 15, 2020
0 parents commit c1c6c06
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM exions/github-actions-git:latest

COPY entrypoint.sh /entrypoint.sh

RUN chmod u+x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 eXions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Merge Upstream
Merge changes from an upstream repository branch into a current repository branch. For example, updating changes from the repository that was forked from.

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

## Usage

### Set up for manual trigger
copy and commit this to `.github/workflows/merge-upstream.yml` in your default branch of your repository.

```yaml
name: Manual Merge Remote Action
on:
workflow_dispatch:
inputs:
upstream:
description: 'Upstream repository owner/name. Eg. exions/merge-upstream'
required: true
default: 'master'
branch:
description: 'Branch to merge'
required: true
default: 'master'

jobs:
merge-upstream:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Merge Upstream
uses: exions/merge-upstream@v1
with:
upstream: ${{ github.event.inputs.upstream }}
branch: ${{ github.event.inputs.branch }}
```
### Set up for scheduled trigger
```yaml
name: Scheduled Merge Remote Action
on:
schedule:
- cron: '0 0 * * 1'
# scheduled for 00:00 every Monday

jobs:
merge-upstream:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
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
```
Reference:
- [Triggering a workflow with events](https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#triggering-a-workflow-with-events)
## How to run this action manually
This action can trigger manually as needed.
1. Go to `Actions` at the top of your Github repository
2. Click on `Manual Undo Push Action` (or other name you have given) under `All workflows`
3. You will see `Run workflow`, click on it
4. Fill in the branch to undo the most recent push (⚠️ make sure it is correct)
5. Click `Run workflow`
6. Check your branch commit history
21 changes: 21 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Merge Upstream"
description: "Merge changes from the uppstream repo you had forked from."
author: "eXions"
branding:
icon: git-merge
color: black

inputs:
upstream:
description: 'Upstream repository owner/name. For example, exions/merge-upstream'
required: true
branch:
description: 'This branch to merge from and to. For example, master'
default: 'master'

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.upstream }}
- ${{ inputs.branch }}
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -eux

cd "${GITHUB_WORKSPACE}"

git remote add -f "https://github.com/$1.git"
git branch ${GITHUB_REF}
git merge --ff-only upstream/${GITHUB_REF}
git push

0 comments on commit c1c6c06

Please sign in to comment.