GitHub
GitHub是一个为全球开发者提供代码仓库的平台,上面主要存放一些开发者开源的项目代码,也可以将代码库设置为私人不对外共享。GitHub提供免费和付费账户,两者都可以对代码进行公开或私有,只是付费账户功能更多。存放在上面的代码管理通过使用[[Git]]工具为进行版本管理 这个平台极大的推动了全球项目开源的进步。因为几乎大部分的开发者都会将自己的开源项目放在GitHub上分享。 截止2020年1月GitHub已经有超过4000万用户注册和1.9亿代码库。它已经成为了世界上最大的代码存放网站和[[开源]]社区 2018年6月4日晚,GitHub被微软以75亿美元的股票收购。
GitHub Actions 工作流程
GitHub跟GitLab一样,支持配置CI/CD 工作流程。不过GitHub的叫作Actions。默认官方提供了MAC OS 、Linux、Windows几种runners来执行Actons。如果想使用自己的服务器来构建任务也是可以的,不过使用自己的服务器用来配置runners官方只允许用在私有仓库中。因为是为了防止公共仓库的代码有恶意程序导致私有服务器被入侵。
创建工作流
在仓库的根目录下创建.github/workflows目录,在该目录创建一个yml文件来编写工作流的内容
官方示例:github-actions-demo.yml
name: GitHub Actions Demo
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."Auto token配置
Actions需要使用个人访问令牌来替代密码进行身份验证,配置路径如下
profile--settings--Developer settings--Personal access tokens--Tokens
Actions配置刚才生成的token
PROJECT--Settings--Secrets--Actions--New repository secret
Fork别人的仓库后自己修改并同步更新别人的源仓库
# 拉取fork到自己仓库的代码到本地
git clone https://github.com/txdier/Draco-OpenWrt-GL-AX1800.git
# 自己在本地修改后提交
git add .
git commit -, "commit change"
git push origin main
# 配置源仓库为自己仓库的上游仓库
git remote add upstream https://github.com/draco-china/Draco-OpenWrt-GL-AX1800.git
# 将源仓库合并到fork后的自己仓库,如果有冲突就处理冲突
git merge upstream/main
# 最后提交到本地仓库
git add .
git commit -m 'change something'
git push origin main
最后更新于