Skip to content

Commit 25fdb83

Browse files
committed
Update README and check for errors
1 parent 818d3d0 commit 25fdb83

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ Github Mirror is a [GitHub Action](https://github.com/features/actions) that kee
44
a mirror of an external repository. It will synchronize all branches and commits from the specified repository, it
55
will not copy non-Git data such as Pull Requests.
66

7-
## Setup
7+
## Create from Template
8+
If you'd prefer to use the GitHub UI instead of the CLI, you can use the [template repository](https://github.com/bridgelightcloud/github-mirror-template).
9+
10+
Steps:
11+
1. Click [Use this template](https://github.com/bridgelightcloud/github-mirror-template/generate).
12+
2. Name your repository
13+
3. Edit `.github/workflows/mirror.yml` and enter the URL you wish to mirror where it says `origin: ''`
14+
4. Commit your change
15+
16+
## Manual Setup
817
To create a mirror, start by creating a repository locally and creating a branch to hold the workflow file. The branch
918
should be named such that it will not conflict with a branch name in the source repository.
1019

@@ -50,7 +59,8 @@ $ git -C mirror push -u origin __mirror
5059
```
5160

5261
The workflow will start immediately and copy the source repository. The workflow will continue to run on the schedule
53-
specified on the `cron` line (in the example above, 3 AM UTC every day).
62+
specified on the `cron` line (in the example above, 3 AM UTC every day). You can also run the workflow manually
63+
by selecting it in the Actions tab on GitHub.
5464

5565
## License
5666
The code is trivial, as such this repository is licensed under the Creative Commons CC-0 license.

action.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
REMOTE="${1}"
44

5-
git clone --bare "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" .
6-
git remote add --mirror=fetch mirror "${REMOTE}"
7-
git fetch mirror +refs/heads/*:refs/remotes/origin/*
8-
git push --force --mirror --prune origin
5+
if [ -z "${REMOTE}" ]; then
6+
echo Please specify an origin
7+
exit 1
8+
fi
9+
10+
git clone --bare "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" . || exit 1
11+
git remote add --mirror=fetch mirror "${REMOTE}" || exit 1
12+
git fetch mirror +refs/heads/*:refs/remotes/origin/* || exit 1
13+
git push --force --mirror --prune origin || exit 1

0 commit comments

Comments
 (0)