15. In CI with the GitHub Action¶
The k11 Release Gate Action runs the gate on every pull request and posts the decision as one comment, updated on every push. Adding it is one line:
The action's own documentation has the full usage guide, reference and design notes. This chapter covers what you need to get it right the first time.
Start with what you have: JUnit¶
You don't need any K11 tool to start. Step 1, a policy, because the built-in one requires API functional tests:
# .qa-mcp/release-policy.yaml
name: Release policy
required: [junit]
max_age_hours: 24
approvers: ["@your-team-lead"]
Step 2, the workflow:
name: Release gate
on: pull_request
permissions:
contents: read
pull-requests: write # for the comment
jobs:
test-and-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: pip install -r requirements.txt pytest
- name: Tests
run: pytest --junitxml=test-results/junit.xml
continue-on-error: true # let the gate decide, and explain
- uses: K11-Software-Solutions/k11techlab-release-gate-action@v1
Open a pull request: one comment appears with the verdict and the evidence table. From here, add tools one at a time.
How it works¶
The action is a composite of five steps: set up Python, install the gate at a pinned version, evaluate, upload the decision, and enforce.
- Evaluate never fails on the verdict. The comment, job summary and artifact are always written; only then does a separate step fail the job. A blocked pull request shows why, not just a red cross.
- Change-aware by default. On a pull request (
base: auto) it diffs against the PR's base branch.actions/checkoutfetches one commit by default, so the action fetches the base branch and deepens the history if it needs to;fetch-depth: 0skips that. - Degrades, doesn't fail. A base branch it can't find, or a comment it can't post, becomes a warning, and the gate still decides.
- One comment. The comment carries a hidden marker; each run updates it instead of adding another.
Inputs and outputs¶
| Input | Default | |
|---|---|---|
fail-on |
block |
fail the job at this verdict or worse: block, needs-human, conditions, never |
base |
auto |
the PR's base branch; none turns change-awareness off; or a ref such as origin/main |
policy |
defaults to .qa-mcp/release-policy.yaml |
|
label |
PR #n, the tag, or the short commit |
|
working-directory |
. |
for monorepos |
comment, upload |
true |
|
version |
0.4.0 |
the gate version, pinned |
Outputs: verdict, blockers, needs-human, conditions, decision-json, decision-markdown.
Evidence from other jobs¶
Real pipelines run tests in parallel jobs, so the reports have to reach the gate's runner at the paths the policy looks in. A plain
actions/download-artifact puts each artifact in a folder named after it, and the gate won't find anything. The pattern that works
(and is tested on GitHub's runners) is to upload the whole .qa-mcp/ folder from each test job and merge them back:
# in each test job
- uses: actions/upload-artifact@v4
if: always()
with: { name: qa-api, path: .qa-mcp/, include-hidden-files: true } # .qa-mcp is a hidden folder
# in the gate job
- uses: actions/download-artifact@v4
with: { pattern: "qa-*", merge-multiple: true, path: .qa-mcp }
- uses: K11-Software-Solutions/k11techlab-release-gate-action@v1
Upload the whole folder, not a single report folder: uploading .qa-mcp/contract-report/ alone makes that folder the artifact's root,
and the file comes back as .qa-mcp/contract-report.json, in the wrong place.
When a person is needed¶
needs_human means "don't block, but a named person must look". Make it a real approval with a GitHub environment that has required
reviewers:
jobs:
gate:
runs-on: ubuntu-latest
outputs: { verdict: "${{ steps.gate.outputs.verdict }}" }
steps:
- uses: actions/checkout@v4
- id: gate
uses: K11-Software-Solutions/k11techlab-release-gate-action@v1
with: { fail-on: block }
sign-off:
needs: gate
if: needs.gate.outputs.verdict == 'needs_human'
runs-on: ubuntu-latest
environment: release-approval # Settings → Environments → required reviewers
steps:
- run: echo "Approved"
Limits to know¶
- Fork pull requests get a read-only token, so the comment is skipped with a warning; the verdict, summary and artifact still work.
Don't check out and run fork code under
pull_request_target. - Monorepos: one gate per service with
working-directory, andcomment: false, because one PR has one gate comment. - Evidence age comes from each report's own timestamp; reports committed to the repository will be stale.