综合练习
为开源仓库提 PR + 配 Actions CI。
40 分钟
综合练习
本课串联 git-github-essentials 全程:Fork → 分支 → commit → PR → Issue → Actions CI →(可选)Pages。对应 git-github 路线图 毕业节点。
前置:完成 git-essentials 与前面 11 课;CI 细节可查阅 github-actions-essentials。
学习目标
- 独立完成一次对开源项目的 docs 类 PR
- 在自己的练习仓配置 PR 触发的 CI
- 对照路线图打勾全部 git-github 节点
练习 A:开源 Docs PR(推荐)
- 在 git-github 路线图 选一个 good first issue 或自行发现 docs typo 的仓库
- Fork → clone 你的 fork
- 开 Issue(可选):「fix typo in README line 42」
- 分支 + commit + push:
git clone git@github.com:YOU/upstream-project.git
cd upstream-project
git remote add upstream git@github.com:ORIGINAL/upstream-project.git
git switch -c docs/fix-readme-typo
# 编辑 README
git commit -m "docs: fix typo in installation section
Closes #YOUR_ISSUE_IF_ANY"
git push -u origin docs/fix-readme-typo
- 开 PR:填模板、等 CI、根据 review 修改
- 合并后
git fetch upstream && git switch main && git merge upstream/main
练习 B:自建练习仓 + CI
在 personal 或 org 仓完成:
# .github/workflows/pr-check.yml
name: PR Check
on:
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Replace with real lint/test for your stack"
- run: test -f README.md
git switch -c chore/add-pr-workflow
git add .github/workflows/pr-check.yml
git commit -m "ci: add PR check workflow"
git push -u origin chore/add-pr-workflow
# 开 PR,确认 Checks 运行
Settings → Branches 为 main 开启 Require status checks。
练习 C:Pages 小站(可选)
在练习仓 docs/ 放:
<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="utf-8"><title>Git GitHub Practice</title></head>
<body>
<h1>git-github-essentials 毕业页</h1>
<p>路线图:<a href="/roadmaps/git-github">/roadmaps/git-github</a></p>
</body>
</html>