From d8b47104554f1b18403401b0dc7be18cb0283a90 Mon Sep 17 00:00:00 2001 From: Martin Bjeldbak Madsen Date: Tue, 11 Feb 2020 11:17:58 +1000 Subject: [PATCH] Initial action code --- Dockerfile | 5 +++++ README.md | 25 +++++++++++++++++++++++++ action.yml | 26 ++++++++++++++++++++++++++ entrypoint.sh | 9 +++++++++ 4 files changed, 65 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..681e7b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:3.11 + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e1b4b39 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +

+ typescript-action status +

+ +# 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' diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..cdd8126 --- /dev/null +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..d85a19a --- /dev/null +++ b/entrypoint.sh @@ -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