Skip to content

Commit

Permalink
Initial action code
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbjeldbak committed Feb 11, 2020
0 parents commit d8b4710
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:3.11

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p align="center">
<a href="https://github.com/net-engine/github-action-repository-sync"><img alt="typescript-action status" src="https://github.com/net-engine/github-action-repository-sync/workflows/build-test/badge.svg"></a>
</p>

# Git Repository Sync Action

A [GitHub action](https://github.com/features/actions) to push changes to a branch in a current GitHub repository to any remote repository, i.e. another GitHub, GitLab, AWS CodeCommit repository.

Inspired by the following actions

* [wei/git-sync](https://github.com/wei/git-sync)
* [pixta-dev/repository-mirroring-action](https://github.com/pixta-dev/repository-mirroring-action)

## Inputs

### `who-to-greet`

**Required** The name of the person to greet. Default `"World"`.


## Example usage

uses: actions/hello-world-docker-action@v1
with:
who-to-greet: 'Mona the Octocat'
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Git Repository Sync
description: Sync current repository to a remote repository on GitHub, GitLab, AWS CodeCommit, etc.
author: NetEngine
inputs:
ssh_private_key:
description: SSH private key for ssh connection to the target repository
required: false
source_branch:
description: The branch from this repository that you want to push to the remote
required: false
default: master
target_branch:
description: The branch from the remote repository that you want to push the source_branch to
required: false
default: master
target_repo_url:
description: Target git repository URL
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.ssh_private_key }}
- ${{ inputs.source_branch }}
- ${{ inputs.target_branch }}
- ${{ inputs.target_repo_url }}
9 changes: 9 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -l

# Setup SSH
mkdir ~/.ssh
echo "$INPUT_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

git remote add destination "$INPUT_TARGET_REPO_URL"
git push destination "$INPUT_SOURCE_BRANCH:$INPUT_TARGET_BRANCH" -f

0 comments on commit d8b4710

Please sign in to comment.