Skip to content

Commit

Permalink
Merge pull request #21 from devatherock/20-one-image
Browse files Browse the repository at this point in the history
chore: Stopped publishing drone-git-sync and vela-git-sync images
  • Loading branch information
devatherock authored Oct 30, 2021
2 parents 6a6adc2 + 2936b5d commit c127d25
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 97 deletions.
22 changes: 6 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,9 @@ jobs:
at: ~/git-sync
- run: |
TAG=${CIRCLE_SHA1:0:8}
docker build -t devatherock/drone-git-sync:$TAG -f docker/Dockerfile .
docker tag devatherock/drone-git-sync:$TAG devatherock/drone-git-sync:latest
docker tag devatherock/drone-git-sync:$TAG devatherock/vela-git-sync:$TAG
docker tag devatherock/drone-git-sync:$TAG devatherock/vela-git-sync:latest
docker tag devatherock/drone-git-sync:$TAG devatherock/git-sync:$TAG
docker tag devatherock/drone-git-sync:$TAG devatherock/git-sync:latest
docker build -t devatherock/git-sync:$TAG -f docker/Dockerfile .
docker tag devatherock/git-sync:$TAG devatherock/git-sync:latest
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push devatherock/drone-git-sync:$TAG
docker push devatherock/drone-git-sync:latest
docker push devatherock/vela-git-sync:$TAG
docker push devatherock/vela-git-sync:latest
docker push devatherock/git-sync:$TAG
docker push devatherock/git-sync:latest
Expand All @@ -99,6 +91,8 @@ jobs:
- v1-dependencies-
- run: |
sh functional-tests.sh
- store_test_results:
path: build/test-results
- save_cache:
paths:
- ~/.gradle
Expand All @@ -115,12 +109,8 @@ jobs:
TAG=${CIRCLE_TAG#v}
DEV_TAG=${CIRCLE_SHA1:0:8}
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker pull devatherock/drone-git-sync:$DEV_TAG
docker tag devatherock/drone-git-sync:$DEV_TAG devatherock/drone-git-sync:$TAG
docker tag devatherock/drone-git-sync:$TAG devatherock/vela-git-sync:$TAG
docker tag devatherock/drone-git-sync:$TAG devatherock/git-sync:$TAG
docker push devatherock/drone-git-sync:$TAG
docker push devatherock/vela-git-sync:$TAG
docker pull devatherock/git-sync:$DEV_TAG
docker tag devatherock/git-sync:$DEV_TAG devatherock/git-sync:$TAG
docker push devatherock/git-sync:$TAG
notify:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### Changed
- fix: Fixed a few Codacy code violations

### Removed
- [#7](https://github.com/devatherock/git-sync/issues/20): Publishing of `drone-git-sync` and `vela-git-sync` images

## [1.1.0] - 2021-01-27
### Changed
- test([#9](https://github.com/devatherock/git-sync/issues/9)): Added unit tests
Expand Down
67 changes: 0 additions & 67 deletions DOCS.md

This file was deleted.

79 changes: 72 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[![CircleCI](https://circleci.com/gh/devatherock/git-sync.svg?style=svg)](https://circleci.com/gh/devatherock/git-sync)
[![Version](https://img.shields.io/docker/v/devatherock/vela-git-sync?sort=semver)](https://hub.docker.com/r/devatherock/vela-git-sync/)
[![Version](https://img.shields.io/docker/v/devatherock/git-sync?sort=semver)](https://hub.docker.com/r/devatherock/git-sync/)
[![Coverage Status](https://coveralls.io/repos/github/devatherock/git-sync/badge.svg?branch=master)](https://coveralls.io/github/devatherock/git-sync?branch=master)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09d2da01eba4895b7d4709880e5c548)](https://www.codacy.com/gh/devatherock/git-sync/dashboard?utm_source=github.com&utm_medium=referral&utm_content=devatherock/git-sync&utm_campaign=Badge_Grade)
[![Docker Pulls](https://img.shields.io/docker/pulls/devatherock/vela-git-sync.svg)](https://hub.docker.com/r/devatherock/vela-git-sync/)
[![Docker Image Size](https://img.shields.io/docker/image-size/devatherock/vela-git-sync.svg?sort=date)](https://hub.docker.com/r/devatherock/vela-git-sync/)
[![Docker Image Layers](https://img.shields.io/microbadger/layers/devatherock/vela-git-sync.svg)](https://microbadger.com/images/devatherock/vela-git-sync)
[![Docker Pulls](https://img.shields.io/docker/pulls/devatherock/vela-git-sync.svg)](https://hub.docker.com/r/devatherock/git-sync/)
[![Docker Image Size](https://img.shields.io/docker/image-size/devatherock/git-sync.svg?sort=date)](https://hub.docker.com/r/devatherock/git-sync/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# git-sync
CI plugin to sync the contents of a git repository with another
Expand All @@ -19,14 +18,80 @@ docker run --rm \
-e PLUGIN_TARGET_BRANCH=test \
-v path/to/repo:/repo \
-w=/repo \
devatherock/drone-git-sync:latest
devatherock/git-sync:1.1.0
```

### CI
Please refer [docs](DOCS.md)
#### Config
The following parameters/secrets can be set to configure the plugin.

**Parameters**
* **target_repo** - Git URI of target repository. If not specified, same as the source repo
* **target_branch** - Branch to sync to, in target repository. Optional, defaults to master
* **start_commit** - Commit sha of the first commit to sync. All commits after that will be synced. If not specified,
commit sha of the penultimate tag will be used. And if no tags are present, all commits up to the 100th will be synced
* **debug** - Flag to enable debug logs. Optional, by default, debug logs are disabled

**Secrets**

The following secret values can be set to configure the plugin.

* **GIT_SYNC_TOKEN** - Github API token with push access to the repository. Required if HTTP URI of target repository
is used

#### drone.io

```yaml
git-sync:
when:
ref: refs/tags/v*
event: tag
image: devatherock/git-sync:1.1.0
target_branch: prod
secrets: [ git_sync_token ]
```
#### vela
```yaml
steps:
- name: git-sync
ruleset:
tag: refs/tags/v*
event: tag
image: devatherock/git-sync:1.1.0
secrets: [ git_sync_token ]
parameters:
target_branch: prod
```
#### CircleCI
To add SSH key with write access to target repository, follow these [instructions](https://circleci.com/docs/2.0/add-ssh-key/)
```yaml
version: 2
jobs:
sync:
docker:
- image: devatherock/git-sync:1.1.0
working_directory: ~/my-source-repo
environment:
PLUGIN_TARGET_REPO: "git@bitbucket.org:xyz/my-target-repo.git" # Git URI of target repository. If not specified, same as the source repo
PLUGIN_TARGET_BRANCH: master # Branch to sync to in target repository. Optional, defaults to master
PLUGIN_START_COMMIT: 29186cd # Commit sha of the first commit to sync. All commits after that will be synced. If not specified, commit sha of the penultimate tag will be used. And if no tags are present, all commits up to the 100th will be synced
PLUGIN_DEBUG: false # Flag to enable debug logs. Optional, by default, debug logs are disabled
GIT_SYNC_TOKEN: xyz # Github API token with push access to the repository. Required if HTTP URI of target repository is used
steps:
- checkout
- add_ssh_keys:
fingerprints:
- "ssh key fingerprint" # Fingerprint of SSH key with write access to target repository
- run: sh /scripts/entry-point.sh
```
## Tests
To test the latest plugin images, run the below command
To test the latest plugin image, run the below command
```shell
sh functional-tests.sh
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,31 @@ class SyncGitReposDockerSpec extends Specification {
@Shared
def config = [
'drone' : [
'image' : 'devatherock/drone-git-sync:latest',
'envPrefix' : 'PLUGIN_',
'emailVar' : 'DRONE_COMMIT_AUTHOR_EMAIL',
'usernameVar': 'DRONE_COMMIT_AUTHOR'
],
'vela' : [
'image' : 'devatherock/vela-git-sync:latest',
'envPrefix' : 'PARAMETER_',
'emailVar' : 'BUILD_AUTHOR_EMAIL',
'usernameVar': 'BUILD_AUTHOR'
],
'circleci': [
'image' : 'devatherock/git-sync:latest',
'envPrefix' : 'PLUGIN_',
'emailVar' : 'CIRCLE_USERNAME',
'usernameVar': 'CIRCLE_USERNAME'
]
]

@Shared
String dockerImage = 'devatherock/git-sync:latest'

String currentBranch = System.getenv('CURRENT_BRANCH')
String testBranch = 'func-test'

void setupSpec() {
System.setProperty('java.util.logging.SimpleFormatter.format', '%5$s%n')
ProcessUtil.executeCommand("docker pull ${config['drone'].image}")
ProcessUtil.executeCommand("docker pull ${config['vela'].image}")
ProcessUtil.executeCommand("docker pull ${config['circleci'].image}")
ProcessUtil.executeCommand("docker pull ${dockerImage}")
}

void setup() {
Expand Down Expand Up @@ -68,7 +66,7 @@ class SyncGitReposDockerSpec extends Specification {
'-e', "GIT_SYNC_TOKEN=${System.getenv('GIT_TOKEN')}",
'-e', "${config[ci].emailVar}=devatherock@gmail.com",
'-e', "${config[ci].usernameVar}=devatherock",
config[ci].image])
dockerImage])

then:
output[0] == 0
Expand Down

0 comments on commit c127d25

Please sign in to comment.