GitHub使用方法
GitHub加速访问
1. 修改host文件达到加速目的
以下方法被写在一个python文件中,可以直接使用github faster执行python文件进行修改刷新
获取GitHub网站的最快地址,使用https://www.ipaddress.com/开获取GitHub的IP地址
修改hosts文件,Mac和Linux在
/etc/hosts
下,Windows在通常在C:\windows\System32\drivers\etc\hosts
下,在结尾添加以下地址的IP1
2
3
4
5
6
7
8
9
10
11
12
13140.82.114.4 github.com
199.232.69.194 github.global.ssl.fastly.net
64.71.168.201 github.community
199.232.68.133 avatars.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 githubusercontent.com
199.232.96.133 user-images.githubusercontent.com刷新hosts文件,Mac和Linux可以使用
sudo killall -HUP mDNSResponder
,Windows使用ipconfig /flushdns
参考文档:Mac 解决GitHub下载速度太慢问题
2. 使用加速镜像克隆
该方法只适用与对代码仓库进行克隆,不支持ssh方法
使用 github.com.cnpmjs.org
来替换原本的网站中的 github.com
如 git clone https://github.com/stolenzc/github_faster.git
替换为 git clone https://github.com.cnpmjs.org/stolenzc/github_faster.git
快速项目检索
检索方法:
1 | in:name xxx # 按照项目名/仓库名搜索(大小写不敏感) |
注意:多个条件之间可以使用空格隔开
Release发包
- 在项目的release窗格下,点击
Draft a new release
- 填入Tag版本,描述之类的东西,然后点击或者将文件拖入到
Attach binaries by dropping them here or selecting them.
- 点击
Publish release
即可完成发包,如果是测试包,可以勾选上this is a pre-release
GitHub Action
介绍
GitHub官方action仓库:Github Action官方市场,第三方仓库:wesome actions
使用action方式:使用git的指针概念,详情参考Github Docs
1 | actions/setup-node@74bc508 # 指向一个 commit |
配置
在项目根目录下的.github/workflows/
下的yml文件
yml文件配置:
name: workflow的名称,如果未设置默认为yml文件名
on: 触发action的条件,可选为
on.<push|pull_request>.<tags|branches>
jobs: workflow的工作主体,表示每一项具体的工作,jobs下面通常需要写清楚job_id,可以自定义。如
jobs:build
。job_id下面为以下字段:name
: 定义字段任务说明needs
: 表示任务的依赖关系,表示运行该任务之前必须运行什么。runs-on
: 运行任务需要的虚拟机环境,可选参数为:ubuntu-latest
,ubuntu-18.04
或ubuntu-16.04
windows-latest
,windows-2019
或windows-2016
macOS-latest
或macOS-10.14
steps
: 每个job包含的步骤,可以配置为:name
: 步骤名称uses
: 使用的actionwith
: github action的入参run
: 执行的命令env
: 设置为环境变量
实例
hexo项目编译并发送到阿里云ESC的指定目录
1 | name: Hexo build and deploy |
该配置需要在secret里面配置阿里云的私钥,然后将阿里云的公钥添加到阿里云的
~/.ssh/authorized_keys
文件中添加阿里云中生成的公钥该配置表示直接将hexo编译后的deploy下的文件拷贝到/blog/下,没有二级目录。
参考内容:阮一峰博客, Github Action发布阿里云ECS