-
Notifications
You must be signed in to change notification settings - Fork 85
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
Yuki Kimura
committed
Sep 26, 2019
0 parents
commit 02f1627
Showing
6 changed files
with
107 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.10 | ||
|
||
RUN apk update && apk upgrade && \ | ||
apk add --no-cache git openssh | ||
|
||
COPY mirror.sh /mirror.sh | ||
COPY setup-ssh.sh /setup-ssh.sh | ||
|
||
ENTRYPOINT ["/mirror.sh"] |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 PIXTA Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# README | ||
|
||
A GitHub Action for mirroring a repository to another repository on GitHub, GitLab, BitBucket, AWS CodeCommit, etc. | ||
|
||
This will copy all commits, branches and tags. | ||
|
||
>⚠️ Note that the other settings will not be copied. Please check which branch is 'default branch' after the first mirroring. | ||
## Usage | ||
|
||
Customize following example workflow and save as .github/workflows/main.yml on your source repository. | ||
|
||
cf. [Creating and using secrets](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) . | ||
|
||
```yaml | ||
name: Mirroring | ||
|
||
on: [push, delete] | ||
|
||
jobs: | ||
to_gitlab: | ||
runs-on: ubuntu-18.04 | ||
steps: # <-- must use actions/checkout@v1 before mirroring! | ||
- uses: actions/checkout@v1 | ||
- uses: pixta-dev/repository-mirroring-action@v1 | ||
with: | ||
target_repo_url: | ||
[email protected]:<username>/<target_repository_name>.git | ||
ssh_private_key: # <-- use 'secrets' to pass credential information. | ||
${{ secrets.GITLAB_SSH_PRIVATE_KEY }} | ||
|
||
to_codecommit: # <-- different jobs are executed in parallel. | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: pixta-dev/repository-mirroring-action@v1 | ||
with: | ||
target_repo_url: | ||
ssh://git-codecommit.<somewhere>.amazonaws.com/v1/repos/<target_repository_name> | ||
ssh_private_key: | ||
${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY }} | ||
ssh_username: # <-- (for codecommit) you need to specify ssh-key-id as ssh username. | ||
${{ secrets.CODECOMMIT_SSH_PRIVATE_KEY_ID }} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "Mirroring Repository" | ||
description: "Mirror a repository to another repository on GitHub, GitLab, BitBucket, AWS CodeCommit, etc." | ||
branding: | ||
icon: "archive" | ||
color: "blue" | ||
inputs: | ||
ssh_private_key: | ||
description: "SSH private key for ssh connection to the target repository" | ||
required: false | ||
target_repo_url: | ||
description: "Target url" | ||
required: true | ||
ssh_username: | ||
description: "Username for ssh connection" | ||
required: false | ||
default: "git" | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
set -eu | ||
|
||
/setup-ssh.sh | ||
|
||
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -l $INPUT_SSH_USERNAME" | ||
git remote add mirror "$INPUT_TARGET_REPO_URL" | ||
git push --tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*" |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
set -eu | ||
|
||
mkdir ~/.ssh | ||
echo "$INPUT_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa |