| English | 中文 |
Original Links:
Multi-repository teams are most prone to CI fragmentation:
Reusable workflows extract common CI logic using workflow_call, allowing business repositories to call a unified template.
Public repository:
org/.github
.github/workflows/
java-ci.yml
node-ci.yml
security-scan.yml
Public workflow:
name: java-ci
on:
workflow_call:
inputs:
java-version:
required: false
type: string
default: "17"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: $
- run: mvn test
Business repository call:
name: ci
on:
pull_request:
push:
branches: [main]
jobs:
java-ci:
uses: org/.github/.github/workflows/java-ci.yml@v1
with:
java-version: "21"
When business repositories call public workflows, do not use @main long-term.
Recommended:
uses: org/.github/.github/workflows/java-ci.yml@v1
This ensures that upgrades to the public template do not suddenly affect all repositories.
Branch protection relies on status check names.
The job names in public workflows should be as stable as possible to avoid renaming that causes main branch protection to fail.
Explicitly declare permissions in public workflows:
permissions:
contents: read
Elevate permissions individually only when writing PR comments, uploading security results, or publishing packages is required.
Do not write a super workflow to handle all languages.
Split them by language and responsibility:
java-ci.ymlnode-ci.ymlgo-ci.ymldocs-ci.ymlsecurity-scan.ymlrelease.ymlSolution: Use tags or releases for layered upgrades.
Solution: Public templates provide a small number of input parameters, but do not parameterize every detail.
Solution: Even when secrets: inherit can be used, define clear boundaries; high-risk secrets should be restricted to necessary repositories and environments.
When 40+ microservice teams implement GitHub engineering governance, Reusable workflows, Rulesets, and CODEOWNERS are three essential pieces of infrastructure.
They resolve the following respectively: