Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
imba-tjd committed Jan 26, 2021
1 parent e32a8b3 commit 0a0b230
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 谭九鼎
Copyright (c) 2021 IMBA-TJD

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
43 changes: 43 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Rebase Upstream Action

This Action is suitable if you:

* are maintaining a fork
* have changes that are not going to be merged into upstream
* want to keep changes based on the latest upstream

Basically this is doing `git rebase upstream master`. If there are conflicts, it simply fails.

## Typical usage

```yml
# .github/workflows/sync.yml
name: Rebase Upstream
on:
schedule:
- cron: "0 0 * * *"

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 10 # larger than the number of commits you made
- uses: imba-tjd/rebase-upstream-action@master
id: rebase
with:
upstream: https://github.com/<user>/<repo>.git
- uses: ad-m/github-push-action@master
if: steps.rebase.outputs.needs-push
with:
force: true
github_token: ${{ github.token }}
```
## Comparison
* tgymnich/fork-sync and apps/pull: I don't want PRs. Besides there is not way to do a `git rebase` on GitHub website
* repo-sync/github-sync: It's not using rebase or merge. It completely mirrors the upstream. And it can't sync current branch
* wei/git-sync: Very complicated and have the same issue as github-sync. After all its aim is "syncing between two independent repo"
* This one: Not widely tested. Use with caution
46 changes: 46 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Rebase Upstream
description: Use git rebase to sync with upstream
author: imba-tjd
branding:
icon: git-pull-request
color: red

inputs:
upstream:
description: The full HTTPS upstream URL.
required: true
branch:
description: The upstream branch that is rebased on.
required: false
default: master
depth:
description: The fetch depth
required: false
default: 100
outputs:
needs-push:
description: Whether push is needed.
value: ${{ steps.set-output.outputs.needs-push }}
runs:
using: composite
steps:
- run: |
echo adding ${{ inputs.upstream }} && \
git remote add upstream ${{ inputs.upstream }};
echo fetching... && \
git fetch upstream --depth=${{ inputs.depth }};
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com";
git config --local user.name "GitHub Action";
echo rebasing... && \
git rebase upstream/${{ inputs.branch }};
shell: bash
- id: set-output
shell: bash
run: |
if [ "$(git status | grep diverged)" ]; then
echo push is needed.
echo ::set-output name=needs-push::1
fi;

0 comments on commit 0a0b230

Please sign in to comment.