Skip to content
项目

关于

Drone plugin for deploying code using git push

开发工具

这些数字如何统计

可以做什么

  • Push commits to remote repositories via SSH or HTTPS
  • Mirror all refs to a remote repository
  • Auto-commit dirty changes before pushing
  • Tag support with follow-tags option

实测星标增长

24小时
0
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.zh-cn.md

原文

drone-git-push

English | 繁體中文

GoDoc Lint and Testing Trivy Security Scan codecov Docker Pulls

支持 Drone、Woodpecker、GitHub Actions 和 Gitea Actions 的 CI/CD 插件,用于将更改推送到远程 Git 仓库。

目录

功能特点

  • 通过 SSH 或 HTTPS 推送提交到远程仓库
  • 镜像所有 refs 到远程仓库
  • 推送前自动提交更改
  • 支持标签与 follow-tags 选项
  • 推送前执行 rebase
  • 支持强制推送
  • 自定义提交信息
  • 支持空提交
  • 支持 Git LFS

支持平台

CI 平台 状态
Drone 完整支持
Woodpecker 完整支持
GitHub Actions 完整支持
Gitea Actions 完整支持

使用方式

Drone / Woodpecker

基本推送到远程分支:

- name: push commit
  image: appleboy/drone-git-push
  settings:
    branch: master
    remote: [email protected]:foo/bar.git
    ssh_key:
      from_secret: deploy_key

推送并提交更改:

- name: push commit
  image: appleboy/drone-git-push
  settings:
    branch: master
    remote: [email protected]:foo/bar.git
    force: false
    commit: true
    commit_message: "[skip ci] Update generated files"
    ssh_key:
      from_secret: deploy_key

推送到当前仓库:

- name: push commit
  image: appleboy/drone-git-push
  settings:
    remote_name: origin
    branch: gh-pages
    local_ref: gh-pages

镜像所有 refs 到远程仓库:

- name: mirror push
  image: appleboy/drone-git-push
  settings:
    remote: [email protected]:foo/bar-mirror.git
    mirror: true
    ssh_key:
      from_secret: deploy_key

推送并添加标签:

- name: push with tag
  image: appleboy/drone-git-push
  settings:
    branch: master
    remote: [email protected]:foo/bar.git
    commit: true
    tag: v1.0.0
    followtags: true
    ssh_key:
      from_secret: deploy_key

GitHub Actions

- name: Push changes
  uses: appleboy/drone-git-push@master
  with:
    remote: [email protected]:foo/bar.git
    branch: master
    ssh_key: ${{ secrets.DEPLOY_KEY }}

Gitea Actions

- name: Push changes
  uses: appleboy/drone-git-push@master
  with:
    remote: [email protected]:foo/bar.git
    branch: master
    ssh_key: ${{ secrets.DEPLOY_KEY }}

参数说明

参数 说明 默认值
ssh_key 远程主机的私有 SSH 密钥 -
remote 目标远程仓库 URL -
remote_name 本地使用的远程名称 deploy
branch 目标远程分支 master
local_branch 要推送的本地分支或 ref HEAD
path Git 仓库路径 当前目录
force 使用 --force 强制推送 false
skip_verify 跳过 HTTPS 证书验证 false
commit 推送前添加并提交内容 false
commit_message 自定义提交信息 [skip ci] Commit dirty state
empty_commit 创建空提交 false
no_verify 跳过 pre-commit 和 commit-msg false
tag 要添加到提交的标签 -
followtags 使用 --follow-tags 选项推送 false
rebase 推送前执行 --rebase false
mirror 使用 --mirror 推送所有 refs false
author_name 提交的作者名称 CI 提交作者
author_email 提交的作者电子邮件 CI 提交作者电子邮件

认证方式

SSH 密钥

提供私有 SSH 密钥进行认证:

settings:
  ssh_key:
    from_secret: deploy_key

HTTPS 账号密码

使用 netrc 凭证进行 HTTPS 认证:

settings:
  username:
    from_secret: git_username
  password:
    from_secret: git_password

从源码构建

构建二进制文件:

go build
go test

构建 Docker 镜像:

# 构建 Linux amd64 版本
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-git-push

# 构建 Docker 镜像
docker build --rm -t appleboy/drone-git-push -f docker/Dockerfile .

使用 Docker 运行

docker run --rm \
  -e DRONE_COMMIT_AUTHOR=Octocat \
  -e [email protected] \
  -e PLUGIN_SSH_KEY="$(cat "${HOME}/.ssh/id_rsa")" \
  -e PLUGIN_BRANCH=master \
  -e [email protected]:foo/bar.git \
  -e PLUGIN_FORCE=false \
  -v "$(pwd):$(pwd)" \
  -w "$(pwd)" \
  appleboy/drone-git-push

许可证

MIT 许可证 - 详见 LICENSE 文件。

探索相关项目

加载中…