GitHub advanced
Ready to let GitHub test your work, guard your main branch, and help you undo mistakes? GitHub Actions runs jobs for you.
Chapters
- 0:00Introduction
- 0:06Automation: GitHub Actions
- 0:18Where it lives: A tiny workflow
- 0:29Keys: Handle secrets
- 0:42Guard main: Protect your branch
- 0:52Tidy history: Merge or rebase
- 1:04Oops: Undo safely
- 1:13Find the break: Bisect the bug
- 1:23Publish: Tags and releases
- 1:31Watch your back: Let GitHub watch
- 1:46Rescue: Find lost commits
- 1:55Wrap up
Read the transcript
Introduction
Ready to let GitHub test your work, guard your main branch, and help you undo mistakes?
Automation: GitHub Actions
GitHub Actions runs jobs for you. An event, such as a push or a pull request, starts a workflow. Its jobs run on a machine called a runner, one step at a time.
Where it lives: A tiny workflow
Workflows live in the .github/workflows folder. This one runs on every pull request. It checks out the code, then runs your tests.
# .github/workflows/test.yml
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: ./run-tests.shKeys: Handle secrets
Workflows often need keys. Store them as encrypted secrets, never in the file. Give each workflow only the permissions it needs. And be careful with third party actions: pin them to a full commit.
Guard main: Protect your branch
Branch protection rules and rule sets guard main. Require a pull request, require an approving review, and require the tests to pass.
Tidy history: Merge or rebase
A merge joins two histories and keeps both. A rebase replays your commits on top of another branch. It rewrites them, so avoid rebasing work others share.
Oops: Undo safely
To undo a commit that's already shared, revert it. That adds a new commit which reverses the old one. History stays honest.
git log --oneline
git revert 1a2b3c4Find the break: Bisect the bug
When something broke and you don't know when, use git bisect. Mark a bad commit and a good one. Git checks out the middle, you test it, and it narrows down the culprit.
git bisect start
git bisect bad
git bisect good v1.0.0Publish: Tags and releases
A tag names one exact commit. Push the tag to GitHub, and publish a release with notes and downloads.
Watch your back: Let GitHub watch
GitHub can watch your repository for you. Dependabot can raise pull requests that update risky dependencies. Secret scanning looks for keys that slipped in. And a code owners file asks the right people to review.
Rescue: Find lost commits
Thought you lost a commit? Git keeps a local diary called the reflog. Find the commit in the list, then start a new branch from it.
git reflog
git switch -c rescue 9f8e7d6Wrap up
Automate the checks, protect main, and release with care.
Sources
- docs.github.com/en/actions/get-started/understand-github-actions
- docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets
- docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches
- docs.github.com/en/repositories/releasing-projects-on-github/about-releases
- git-scm.com/docs/git-revert
- git-scm.com/docs/git-rebase
- git-scm.com/docs/git-bisect
- docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates
- docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning
- docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
- git-scm.com/docs/git-reflog