forked from mheene/sync-upstream-repo
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e612de8
commit 060e16e
Showing
1 changed file
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |