https://github.com/lpreterite/drone-plugin-git-sync
同步代码至另一个项目的`drone`插件
https://github.com/lpreterite/drone-plugin-git-sync
drone-plugin git
Last synced: 3 months ago
JSON representation
同步代码至另一个项目的`drone`插件
- Host: GitHub
- URL: https://github.com/lpreterite/drone-plugin-git-sync
- Owner: lpreterite
- Created: 2018-12-18T06:25:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T06:14:30.000Z (12 months ago)
- Last Synced: 2025-01-13T10:11:28.622Z (4 months ago)
- Topics: drone-plugin, git
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# drone-plugin-git-sync
[](https://hub.docker.com/r/lpreterite/drone-plugin-git-sync)
同步代码至另一个项目的`drone`插件,主要操作:拉取指定仓库后拷贝代码至相应目录并提交推送。
## Usage
Execute from the working directory:
```sh
MSYS_NO_PATHCONV=1 docker run --rm \
-e PLUGIN_GIT_USERNAME="packy-tang" \
-e PLUGIN_GIT_PASSWORD="******" \
-e PLUGIN_GIT_CONFIG='{"name": "packy-tang", "email": "[email protected]"}' \
-e PLUGIN_REPOSITORY='{"url":"https://github.com/lpreterite/drone-plugin-git-sync.git", "branch":"master"}' \
-e PLUGIN_COPY=dist:public2,dist/index.html:resources/views/index.php \
-v $(pwd):$(pwd) \
-w $(pwd) \
lpreterite/drone-plugin-git-sync
```The setting in drone plugin:
```yml
kind: pipeline
name: defaultsetps:
- name: git-sync
image: lpreterite/drone-plugin-git-sync
settings:
overwrite: "true"
copy:
- "dist:public"
repository:
url: https://github.com/lpreterite/vue-tinymce.git
branch: master
git_config:
name: "Packy-tang"
email: "[email protected]"
git_username:
from_secret: username
git_password:
from_secret: password
```Use ssh and set ssh_key:
```yml
kind: pipeline
name: defaultsetps:
- name: git-sync
image: lpreterite/drone-plugin-git-sync
settings:
overwrite: "true"
copy:
- "dist:public"
repository:
url: ssh://github.com/lpreterite/vue-tinymce.git
branch: master
git_config:
name: "Packy-tang"
email: "[email protected]"
git_ssh_key:
from_secret: ssh_key
```Use ssh:
```yml
kind: pipeline
name: defaultsetps:
- name: git-sync
image: lpreterite/drone-plugin-git-sync
volumes:
- name: sshkeys
path: /ssh/keys/
settings:
overwrite: "true"
copy:
- "dist:public"
repository:
url: ssh://github.com/lpreterite/vue-tinymce.git
branch: master
git_config:
name: "Packy-tang"
email: "[email protected]"
git_ssh: /ssh/keys/id_rsavolumes:
- name: sshkeys
host:
path: /ssh/keys/
```## Options
| env | yml | |
| ---------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| PLUGIN_DEBUG | debug | `boolean` ,默认为`false` ,开启后能打印调试用信息。 |
| PLUGIN_CWD | cwd | `string`, 仓库下载处理目录,默认为`./tmp/` |
| PLUGIN_OVERWRITE | overwrite | `boolean`, 拷贝文件时是否复写文件,默认为"true" |
| PLUGIN_REPOSITORY | repository | `json`, 仓库信息,默认为`{"url":"[Repository Url]", "branch":"master", "commit_label": "update by drone"}` |
| PLUGIN_COPY | copy | `array`, 拷贝文件的设置,设置方式为:"[source path]:[target path]" |
| PLUGIN_GIT_CONFIG | git_config | `json`, git 设置,目前只支持设置`name`和`email`,接受格式:`{ name: '[yourname]', email:'[[email protected]]' }` |
| PLUGIN_GIT_USERNAME | git_auth_username | `string`, 仓库授权的账户,用于 http 方式 push 仓库时使用 |
| PLUGIN_GIT_PASSWORD | git_auth_password | `string`, 仓库授权的密码,用于 http 方式 push 仓库时使用 |
| PLUGIN_GIT_SSH | git_ssh | `string`, 仓库授权私钥地址,用于 ssh 方式 push 仓库时使用 |
| PLUGIN_GIT_SSH_KEY | git_ssh_key | `string`, 仓库授权私址,用于 ssh 方式 push 仓库时使用。 |
| PLUGIN_GIT_CLONE_DEPTH | git_clone_depth | `number`,默认值为`1`, 拉取仓库时保留历史数目,默认设置1,用于加快仓库拉取。 |## Build
```sh
docker build -t lpreterite/drone-plugin-git-sync .
```> `from_secret`作用的参数需要在 drone 版面下找到`SETTINGS->Secrets`进行添加