# Git服务
# Flag
- https://github.com/gitblit/gitblit (opens new window)
- https://github.com/scm-manager/scm-manager (opens new window)
- https://www.mercurial-scm.org (opens new window)
- 代码语法突出 https://github.com/sharkdp/bat (opens new window)
- Git核心方法的可移植的纯C实现 https://github.com/libgit2/libgit2 (opens new window)
代码跟踪分析
- https://sonarcloud.io (opens new window)
- https://semmle.com (opens new window)
- https://www.openhub.net (opens new window)
- https://bestpractices.coreinfrastructure.org (opens new window)
- Gerrit https://www.gerritcodereview.com (opens new window)
Gogs
- https://github.com/gogs/gogs (opens new window)
- https://hub.docker.com/r/gogs/gogs (opens new window)
- 安装教程 (opens new window)
Gitea
- https://github.com/go-gitea/gitea (opens new window)
- https://hub.docker.com/r/gitea/gitea (opens new window)
# GitLab
- https://gitlab.com/xhang/gitlab/wikis/home (opens new window)
- GitLab Community Edition (中文社区版) (opens new window)
- https://hub.docker.com/r/bensonfx/gitlab-ce-zh (opens new window)
- https://github.com/bensonfx/codeserver (opens new window)
- https://hub.docker.com/r/benyoo/gitlab (opens new window)
- https://hub.docker.com/r/imleafz/gitlab-ce-zh (opens new window)
version: '2'
services:
gitlab:
image: 'twang2218/gitlab-ce-zh:11.1.4'
restart: unless-stopped
hostname: 'git.woetu.com'
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://git.woetu.com'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
# 需要配置到 gitlab.rb 中的配置可以在这里配置,每个配置一行,注意缩进。
# 比如下面的电子邮件的配置:
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
# gitlab_rails['smtp_password'] = "password"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = true
# gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
ports:
- '8099:80'
- '442:443'
- '22:22'
volumes:
# - /home/gitlab/config:/home/gitlab/config
# - /home/gitlab/data:/home/gitlab/data
# - /home/gitlab/logs:/home/gitlab/logs
- config:/etc/gitlab
- data:/var/opt/gitlab
- logs:/var/log/gitlab
volumes:
config:
data:
logs:
# GitHub
- https://github.com/all-contributors/all-contributors (opens new window)
- https://github.com/probot/probot (opens new window)
- https://help.github.com/cn (opens new window)
- 发布成功之后
github pages
的Custom domain
配置项就被清空:github-pages-basics (opens new window) - https://codecov.io (opens new window)
- 目录 - P3TERX ZONE (opens new window)
- https://github.com/zenodo/zenodo (opens new window)
- 手动同步fork https://blog.blueskyclouds.com/jsfx/58.html (opens new window)
- https://github.com/wei/git-sync (opens new window)
- https://github.com/repo-sync (opens new window)
- 自动同步fork https://github.com/wei/pull (opens new window)
- GitHub的Java API https://github.com/hub4j/github-api (opens new window)
统计
- GH存档 https://www.gharchive.org (opens new window)
- GitHub每周趋势 https://github.com/SolaTyolo/gold_github_trending (opens new window)
- GitHub每天趋势 https://github.com/yangwenmai/github-trending-backup (opens new window)
- 记录GitHub趋势 https://github.com/xiaobaiha/github-trending-history (opens new window)
- 获取统计信息 https://github.com/shroudedcode/devstats (opens new window)
- 获取动态生成的GitHub统计信息 https://github.com/anuraghazra/github-readme-stats (opens new window)
- 获取访问统计 http://profile-counter.glitch.me/用户名/count.svg
- 历史Star数 https://starchart.cc/用户名/My-Actions.svg
- 你在 GitHub 上看到过的最有意思的项目是什么? - 知乎 (opens new window)
# 访问速度过慢
- https://myssl.com/dns_check.html (opens new window)
- http://tool.chinaz.com/dns (opens new window)
- https://www.ipaddress.com (opens new window)
- Windows设置GitHub的Hosts脚本
- https://codechina.csdn.net/mirrors (opens new window)
- https://github.com/FastGitORG (opens new window)
- github release、archive以及项目文件的加速项目 https://github.com/hunshcn/gh-proxy (opens new window)
- https://gitee.com/mirrors (opens new window)
刷新DNS缓存
- macOS
killall -HUP mDNSResponder
dscacheutil -flushcache
- Windows
ipconfig /flushdns
- Linux
service nscd restart
- Ubuntu
sudo /etc/init.d/dns-clean start
克隆代理地址
- https://github.com/BaseMax/GitHubMirror (opens new window)
- https://github.com/RC1844/FastGithub (opens new window)
- 替换
github.com
为github.com.cnpmjs.org
jlytgs.com/github_
github.dyf62976.workers.dev
github.wuyanzheshui.workers.dev
github.hsmw.workers.dev
github.reycn.workers.dev
github.itzmx.com
# Actions
生成公钥和私钥
ssh-keygen -t rsa -b 4096 -C "yourname@example.com" -f 文件名称 -N ""
(ACTION_DEPLOY_KEY), 或者生成新的个人访问令牌(PERSONAL_TOKEN)https://github.com/settings/tokens/new (opens new window)
- https://github.com/actions (opens new window)
- https://github.com/topics/github-pages (opens new window)
- https://github.com/topics/gh-pages (opens new window)
- https://github.com/topics/deploy (opens new window)
- https://github.com/topics/deployment (opens new window)
- https://github.com/topics/github-actions (opens new window)
- https://github.com/topics/github-action (opens new window)
- https://github.com/sdras/awesome-actions (opens new window)
- https://github.com/topics/workflow (opens new window)
deploy-to-github-pages
、pages
、deploy
- https://github.com/peaceiris/actions-gh-pages (opens new window)
- https://github.com/JamesIves/github-pages-deploy-action (opens new window)
upload release
- https://github.com/wangyoucao577/go-release-action (opens new window)
- https://github.com/elgohr/Publish-Docker-Github-Action (opens new window)
- https://github.com/release-drafter/release-drafter (opens new window)
- https://github.com/xresloader/upload-to-github-release (opens new window)
- https://github.com/svenstaro/upload-release-action (opens new window)
第三方CI
- CI services (opens new window)
- https://github.com/opencpu (opens new window)
- https://github.com/circleci (opens new window)
- https://github.com/codeship (opens new window)
- https://github.com/gocd (opens new window)
- https://github.com/travis-ci (opens new window)
- https://github.com/wercker (opens new window)
# GitWebHook
- 手动部署
Vue项目完成后,执行
npm run build
,然后将生成的dist目录下的文件放到web目录下
- WebHooks自动化部署,流程如下:
配置
Gitea
的WebHook
通知(也可以用码云
、Github
、GitLab
、gogs
,带WebHook
功能就行)
当我们
push
到仓库时,Gitea
会主动发送一个通知到我们的服务器,然后服务器接到通知执行我们部署的脚本,开始自动化构建。
- https://github.com/woytu/webhook-go (opens new window)
- https://github.com/adnanh/webhook (opens new window)
- https://github.com/pre-commit (opens new window)
# 配置接收通知
必备环境
- 以下命令视自己的环境而执行
# git
yum install -y git
# node 由于nodejs自带npm所以就不需要手动安装了
yum install -y nodejs
# vue-cli
npm install -g @vue/cli
# 宝塔面板
- 设置宝塔WebHook插件
宝塔WebHook获取url
param参数需要和脚本里对应起来,我这里写的是pull
http://服务器ip:8888/hook?access_key=5C84B7A5UeXYalfNL6WEpi3jdmmxhFlk3jpvEw02BMo84Ak3¶m=pull
# netcat命令
实现监听端口->响应请求->执行脚本部署
一直监听 9999 端口,有请求就响应
echo
的内容,并执行指定脚本
echo -e "HTTP/1.1 200 ok,glass\r\nConnection: close\r\n\r" | nc -l 0.0.0.0 9999 ; sh /home/update.sh >> /home/logs/webhook.log 2>&1
通过 systemd,可以将这个脚本管理起来,让它永远重启,这样一次部署之后,马上就可以重新监听,等待下一次部署命令。注意要添加 StartLimitInterval ,限制一下执行的频率。
- 最终的
systemd service
如下
[Unit]
Description=Autopull through webhook
After=network.target
[Service]
User=admin
Type=simple
ExecStart=/bin/bash -xc 'echo -e "HTTP/1.1 200 ok,glass\r\nConnection: close\r\n\r" | nc -l 0.0.0.0 9999 ; sh /home/deploy/update.sh >> /home/logs/webhook.log 2>&1'
Restart=always
StartLimitInterval=1min
StartLimitBurst=60
[Install]
WantedBy=multi-user.target
这样就可以实现每次向 master push 代码,自动测试成功并且马上推送到测试环境中。 update.sh 脚本的最后可以加一个 Curl 命令向钉钉或者 slack 发送提醒。