Github - GradedJestRisk/cicd-training GitHub Wiki

Github CI

Write workflow

Use a GitHub Action.

Lint it locally

Trigger CI

CI should be triggered

  • on a pull request
  • on merge on default branch

All events to PR are here.

The push on a pull request is the synchronize event, so pull_request covers pretty everything.

Pull request targeting main branch.

on:
  pull_request:
    branches:
      - 'main'

Merge (push) on main branch.

on:
  push:
    branches:
      - 'main'

https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#running-your-workflow-only-when-a-push-to-specific-branches-occurs

Merge

Strategies

3 type:

  • rebase
  • squash
  • merge

Merge commit

A merge commit occurs when you integrate changes from one Git branch into another. This action results in a new commit on the target branch that ties together the histories of both branches. Unlike a rebase or a squash, a merge commit preserves the entire history of both branches, making it easier to understand the context of changes and decisions made throughout the development process.

in Git

in Github

Squash commit

in Github

Rebase

all commits from the topic branch (or head branch) are added onto the base branch individually without a merge commit. I

in Github

Auto-merge

Merge queues

https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue

⚠️ **GitHub.com Fallback** ⚠️