Dependabot 私有部署指南
本文记录了 Dependabot
私有部署的心路历程。团队使用 GitLab
社区版内网部署,所以试用了 Dependabot 同样在内网部署。
准备工作
因为服务器环境内有 Docker
环境,有利于多项目场景,并且 GitLab
对 GitLab
的支持非常友好,所以部署方案就水到渠成了。
- GitLab CE
- Docker
Docker
Pull dependabot-core
Docker image
$ docker pull dependabot/dependabot-core
Script
创建新仓库,克隆下面的仓库到自己的 GitLab
仓库里
https://github.com/dependabot/dependabot-script
重命名CI配置文件 .gitlab-ci.example.yml
为 .gitlab-ci.yml
具体配置内容自行查看,这里以 NPM
为例
.dependabot:
image: dependabot/dependabot-core
variables:
PACKAGE_MANAGER: $CI_JOB_NAME
before_script:
- bundle install -j $(nproc) --path vendor
script: bundle exec ruby ./generic-update-script.rb
cache:
paths:
- vendor/
npm_and_yarn:
extends: .dependabot
only:
variables:
- $PACKAGE_MANAGER_SET =~ /(\bnpm|yarn\b)/
启动
在上一步克隆的仓库创建 Schedule
来触发 Pipeline
,设置环境变量
PROJECT_PATH
: group/repository 仓库名
PACKAGE_MANAGER_SET
: bundler / composer / npm_and_yarn 依赖包管理方式
DIRECTORY_PATH
: /path/to/point 依赖包文件配置
PULL_REQUESTS_ASSIGNEE
: Integer ID of the user to assign
GITLAB_HOSTNAME
: GitLab Hostname
GITLAB_ACCESS_TOKEN
: GitLab access token
GITHUB_ACCESS_TOKEN
: GitHub access token 用于提高 GitHub 接口限制
以上环境变量都必须填入
完
Schedule
启动后会触发依赖检测,会 创建分支
和 Merge Requests
本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 (CC BY-NC-ND 4.0) 进行许可。