Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreadman committed Mar 19, 2021
1 parent e612de8 commit 060e16e
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
# Sync Upstream Repo Fork

This repository contains an github action to sync your current repository with an upstream repository. The work is greatly inspired by [actions-registry/github-repo-sync-upstream](https://github.com/actions-registry/github-repo-sync-upstream) which didn't work for me.
Added parameter to determine target branch.
This is a Github Action used to merge changes from remote.

This is forked from [mheene](https://github.com/mheene/sync-upstream-repo), with me adding authentication using [GitHub Token](https://docs.github.com/en/actions/reference/authentication-in-a-workflow) and downstream branch options due to the [default branch naming changes](https://github.com/github/renaming).

## Use case

- Perserve a repo while keeping up-to-date (rather than to clone it).
- Have a branch in sync with upstream, and pull changes into dev branch.

## Usage

Example github action:
Example github action [here](https://github.com/THIS-IS-NOT-A-BACKUP/go-web-proxy/blob/main/.github/workflows/sync5.yml):

```YAML
name: CI
name: My_Pipeline_Name

on:
###
env:
# Required, URL to upstream (fork base)
UPSTREAM_URL: "https://github.com/dabreadman/go-web-proxy.git"
# Optional, defaults to main
DOWNSTREAM_BRANCH: "main"
###

on:
schedule:
- cron: "15 14 * * *"
- cron: '30 * * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: GitHub Sync to Upstream Repository
uses: dabreadman/[email protected]
with:
# GitHub public upstream repo
upstream_repo: https://github.com/holger24/AFD.git
branch: main
- name: GitHub Sync to Upstream Repository
uses: dabreadman/[email protected]
with:
upstream_repo: ${{ env.UPSTREAM_URL }}
branch: $$ env.DOWNSTREAM_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN}}
```
This action syncs your repo at branch `main` with the upstream repo ``` https://github.com/holger24/AFD.git ``` every day at 14:15 UTC.
This action syncs your repo (merge changes from `remote`) at branch `main` with the upstream repo ``` https://github.com/dabreadman/go-web-proxy.git ``` every 30 minutes.

## Mechanism

1. Setup an environment using docker.
(Why do that when `Workflow` is inside an environment? I have no idea).
2. Pass arguments into `entrypoint.sh`.
3. `entrypoint.sh` does the heavy lifting.
git clone, set origin/upstream, fetch, merge, push.

0 comments on commit 060e16e

Please sign in to comment.