Sign inSign up

lpreterite/drone-plugin-git-sync

By lpreterite

•Updated over 2 years ago

同步代码至另一个项目的`drone`插件

Image
0

3.0K

lpreterite/drone-plugin-git-sync repository overview

⁠drone-plugin-git-sync

Docker Automated build

同步代码至另一个项目的drone插件,主要操作:拉取指定仓库后拷贝代码至相应目录并提交推送。

⁠Usage

Execute from the working directory:

docker run --rm \
    -e PLUGIN_ACCOUNT='{"username": "packy-tang", "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:

kind: pipeline
name: default

setps:
    - 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_account:
              username:
                  from_secret: username
              password:
                  from_secret: password

Use ssh:

kind: pipeline
name: default

setps:
    - 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_rsa

volumes:
    - name: sshkeys
      host:
          path: /ssh/keys/

Use volumes set must set Trusted with true in [Repository]->[SETTINGS] on drone

⁠Options

envyml
PLUGIN_CWDcwdstring, 仓库下载处理目录,默认为./tmp/
PLUGIN_OVERWRITEoverwritestring, 拷贝文件时是否复写文件,默认为"true"
PLUGIN_REPOSITORYrepositoryjson, 仓库信息,默认为{"url":"[Repository Url]", "branch":"master", "commit_label": "update by drone"}
PLUGIN_COPYcopyarray, 拷贝文件的设置,设置方式为:"[source path]:[target path]"
PLUGIN_GIT_CONFIGgit_configjson, git 设置,目前只支持设置name和email,接受格式:{ name: '[yourname]', email:'[[email protected]]' }
PLUGIN_GIT_ACCOUNTgit_auth_usernamestring, 仓库授权的账户与密码,用于 http 方式 push 仓库时使用,接受格式: { username: '[username]', password: '[******]'}
PLUGIN_GIT_SSHgit_sshstring, 仓库授权私钥地址,用于 ssh 方式 push 仓库时使用

⁠Build

docker build -t lpreterite/drone-plugin-git-sync .

from_secret作用的参数需要在 drone 版面下找到SETTINGS->Secrets进行添加

Tag summary

Content type

Image

Digest

Size

38.7 MB

Last updated

almost 6 years ago

docker pull lpreterite/drone-plugin-git-sync