-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from net-engine/add-action-test
Initial test and working implementation
- Loading branch information
Showing
5 changed files
with
28 additions
and
28 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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
name: "build-test" | ||
on: # rebuild any PRs and main branch changes | ||
name: "test" | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- 'releases/*' | ||
|
||
jobs: | ||
test: # make sure the action works on a clean machine without building | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./ | ||
with: | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
target_repo_url: git@github.com:net-engine/github-action-repository-sync-test.git | ||
source_branch: master | ||
target_branch: master | ||
target_repo_url: git@github.com:net-engine/github-repository-sync-action-test.git |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
FROM alpine:3.11 | ||
|
||
RUN apk update && apk upgrade && \ | ||
apk add --no-cache git openssh-client && \ | ||
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.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 |
---|---|---|
@@ -1,25 +1,35 @@ | ||
<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> | ||
<a href="https://github.com/net-engine/github-repository-sync-action"><img alt="GitHub action build status" src="https://github.com/net-engine/github-repository-sync-action/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. | ||
|
||
Check out a [sample workflow](https://github.com/net-engine/github-repository-sync-action/blob/master/.github/workflows/test.yml). | ||
|
||
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` | ||
### `ssh_private_key` | ||
|
||
**Required** The SSH private key for SSH connection to the target repository. We strongly recommend saving this value within [GitHub secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets). | ||
|
||
**Required** The name of the person to greet. Default `"World"`. | ||
### `target_repo_url` | ||
|
||
**Required** The SSH-based URL to the target repository, e.g. `git@github.com:net-engine/github-repository-sync-action.git` | ||
|
||
## Example usage | ||
|
||
uses: actions/hello-world-docker-action@v1 | ||
uses: netengine/github-repository-sync-action | ||
with: | ||
who-to-greet: 'Mona the Octocat' | ||
|
||
## TODO | ||
|
||
* Support for any to and from branch, similar to [actions/checkout@v2](https://github.com/actions/checkout) | ||
* Make SSH key-based authentication optional to support username/password authentication |
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#!/bin/sh -l | ||
|
||
# Setup SSH | ||
mkdir ~/.ssh | ||
echo "$INPUT_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
mkdir -p /root/.ssh | ||
echo "$INPUT_SSH_PRIVATE_KEY" > /root/.ssh/id_rsa | ||
chmod 600 /root/.ssh/id_rsa | ||
|
||
git remote add destination "$INPUT_TARGET_REPO_URL" | ||
git push destination "$INPUT_SOURCE_BRANCH:$INPUT_TARGET_BRANCH" -f | ||
git push destination "$GITHUB_REF:$GITHUB_REF" -f |