|
1 | 1 | # Sync Upstream Repo Fork
|
2 | 2 |
|
3 |
| -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. |
4 |
| -Added parameter to determine target branch. |
| 3 | +This is a Github Action used to merge changes from remote. |
| 4 | + |
| 5 | +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). |
| 6 | + |
| 7 | +## Use case |
| 8 | + |
| 9 | +- Perserve a repo while keeping up-to-date (rather than to clone it). |
| 10 | +- Have a branch in sync with upstream, and pull changes into dev branch. |
5 | 11 |
|
6 | 12 | ## Usage
|
7 | 13 |
|
8 |
| -Example github action: |
| 14 | +Example github action [here](https://github.com/THIS-IS-NOT-A-BACKUP/go-web-proxy/blob/main/.github/workflows/sync5.yml): |
9 | 15 |
|
10 | 16 | ```YAML
|
11 |
| -name: CI |
| 17 | +name: My_Pipeline_Name |
12 | 18 |
|
13 |
| -on: |
| 19 | +### |
| 20 | +env: |
| 21 | + # Required, URL to upstream (fork base) |
| 22 | + UPSTREAM_URL: "https://github.com/dabreadman/go-web-proxy.git" |
| 23 | + # Optional, defaults to main |
| 24 | + DOWNSTREAM_BRANCH: "main" |
| 25 | +### |
| 26 | + |
| 27 | +on: |
14 | 28 | schedule:
|
15 |
| - - cron: "15 14 * * *" |
| 29 | + - cron: '30 * * * *' |
16 | 30 |
|
17 | 31 | jobs:
|
18 | 32 | build:
|
19 | 33 | runs-on: ubuntu-latest
|
20 | 34 | steps:
|
21 |
| - - uses: actions/checkout@v2 |
22 |
| - - name: GitHub Sync to Upstream Repository |
23 |
| - uses: dabreadman/[email protected] |
24 |
| - with: |
25 |
| - # GitHub public upstream repo |
26 |
| - upstream_repo: https://github.com/holger24/AFD.git |
27 |
| - branch: main |
| 35 | + - name: GitHub Sync to Upstream Repository |
| 36 | + uses: dabreadman/[email protected] |
| 37 | + with: |
| 38 | + upstream_repo: ${{ env.UPSTREAM_URL }} |
| 39 | + branch: $$ env.DOWNSTREAM_BRANCH }} |
| 40 | + token: ${{ secrets.GITHUB_TOKEN}} |
28 | 41 | ```
|
29 | 42 |
|
30 |
| -This action syncs your repo at branch `main` with the upstream repo ``` https://github.com/holger24/AFD.git ``` every day at 14:15 UTC. |
| 43 | +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. |
| 44 | + |
| 45 | +## Mechanism |
| 46 | + |
| 47 | +1. Setup an environment using docker. |
| 48 | + (Why do that when `Workflow` is inside an environment? I have no idea). |
| 49 | +2. Pass arguments into `entrypoint.sh`. |
| 50 | +3. `entrypoint.sh` does the heavy lifting. |
| 51 | + git clone, set origin/upstream, fetch, merge, push. |
0 commit comments