1 Star 0 Fork 0

theajack / cdn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CDN

使用 Github,jsDelivr, TravisCI 搭建一个轻量靠谱的 CDN

实现原理

Github 做 CDN 存储,jsDelivr 做 CDN 服务器, TravisCI 做自动更新。

流程

  1. 本地添加文件到 Git,推送到 Github,触发 TravisCI 执行构建;
  2. TravisCI 拉取最新 Github 文件,打 Tag,发布到 Github Release, 将新版本文件推送回 Github;
  3. 用户访问 jsDelivr 的 CDN 服务器,jsDelivr 到 Github Release 拉取对应版本或者最新版本文件,返回给用户;
  4. 本地更新文件,如此往复触发第一步。

核心代码

language: node_js # 升级版本需要依赖 npm
node_js: stable

install: true # 无需安装依赖,调过安装

branches:
  only:
  - master # 只发布 master 分支

before_script:
- git config --global user.name "travis" # 配置 travis git 信息
- git config --global user.email "travis@miantiao.me"

script:
- git push -f https://$GITHUB_KEY@github.com/$TRAVIS_REPO_SLUG.git `npm version patch -m "%s [ci skip]"` # 打 Tag,发布到 Github Release, 使用 [ci skip] 调过 CI, 防止死循环
- git push -f https://$GITHUB_KEY@github.com/$TRAVIS_REPO_SLUG.git HEAD:master #将新版本文件推送回 Github

CDN 效果

jsDelivr 服务器分布,有服务器位于中国。

jsDelivr

文件浏览和流量统计

jsDelivr 提供了一个可以看 CDN 文件和使用流量的地址:https://www.jsdelivr.com/package/gh/ccbikai/cdn

jsDelivr File

演示

  1. https://cdn.jsdelivr.net/gh/ccbikai/cdn/README.md
  2. https://cdn.jsdelivr.net/gh/ccbikai/cdn@latest/README.md
  3. https://cdn.jsdelivr.net/gh/ccbikai/cdn@0.0.1/README.md
  4. https://cdn.jsdelivr.net/gh/ccbikai/cdn@0.0.5/example/1.jpg
MIT License Copyright (c) 2018 不给力的面条 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

cdn 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/theajack/cdn.git
git@gitee.com:theajack/cdn.git
theajack
cdn
cdn
master

搜索帮助