Pull/Merge Request Flow
This diagram shows the complete flow when a pull request or merge request is opened:Flow Steps
User Action
A developer opens a pull request, pushes a commit, or creates a tag in their Git repository.
Webhook Event
The Git provider (GitHub, GitLab, Bitbucket, or Forgejo) sends a webhook HTTP POST request to the PAC webhook endpoint.
Event Reception
The webhook handler receives the event and validates:
- Webhook signature authentication
- Event payload format
- Skip CI markers (
[skip ci],[ci skip])
Repository Lookup
The controller:
- Finds the matching Repository CRD in Kubernetes
- Retrieves authentication credentials from secrets
- Validates repository configuration
Permission Validation
The ACL system checks:
- User is authorized (org member, collaborator, in OWNERS file)
- Event doesn’t require
/ok-to-testapproval - Repository policy allows execution
Pipeline Discovery
The resolver:
- Fetches the
.tekton/directory from the repository - Parses all YAML files for PipelineRun definitions
- Filters pipelines based on event type and annotations
Pipeline Matching
For each pipeline, check:
on-eventannotation matches event typeon-target-branchmatches target branchon-cel-expressionevaluates to true (if present)on-path-changematches changed files (if present)
Task Resolution
Resolve remote tasks from:
- Tekton Hub (
resolver: hub) - Artifact Hub
- OCI bundles (
resolver: bundles) - Git repositories (
resolver: git)
Variable Substitution
Substitute template variables:
{{repo_url}}→ Git repository clone URL{{revision}}→ Git commit SHA{{target_branch}}→ Pull request target branch{{source_branch}}→ Pull request source branch- Custom variables from ConfigMap
PipelineRun Creation
Create PipelineRun on Kubernetes with:
- Resolved pipeline specification
- Workspaces and volume claims
- Secrets and service accounts
- Labels and annotations for tracking
Execution Monitoring
The watcher monitors the PipelineRun:
- Watches for status changes
- Reports progress to Git provider
- Creates GitHub Checks, GitLab notes, etc.
Status Reporting
As the pipeline executes, report:
- In-progress status with task details
- Task completion and timing
- Log snippets for failures
- Error annotations (GitHub only)
Concurrency Flow
This diagram shows how PAC manages concurrent pipeline executions:Concurrency States
- queued
- started
- completed
When: Concurrency limit reachedBehavior:
- PipelineRun created with
.status.conditions[].reason=Pending - Added to FIFO queue for the repository
- State annotation:
pipelinesascode.tekton.dev/state=queued
Concurrency Configuration
Set concurrency limit with annotation:- Prevent multiple deployments to the same environment
- Limit resource consumption
- Ensure sequential execution for stateful operations
- Avoid race conditions in integration tests
GitOps Command Flow
This diagram shows how GitOps commands (/test, /retest, /cancel) are processed:
Supported Commands
/test [pipeline-name]
/test [pipeline-name]
Purpose: Trigger a specific pipeline or all matched pipelinesUsage:Requirements:
- User must have write access to the repository
- Pipeline must match current event and branch
/retest
/retest
Purpose: Re-run all previously failed pipelinesUsage:Behavior:
- Only re-runs pipelines that failed
- Successful pipelines are not re-run
- Uses current
.tekton/files (not from failed run)
/cancel
/cancel
Purpose: Cancel all running pipelines for the PRUsage:Behavior:
- Deletes all running PipelineRuns
- Does not affect completed pipelines
- Reports cancellation status to Git provider
/ok-to-test
/ok-to-test
Purpose: Approve pipelines for untrusted PRs (from forks)Usage:Requirements:
- Only available when policy requires approval
- User must be repository admin or in OWNERS file
- Approval is one-time (new commits require re-approval)
Auto-Cancellation Flow
When a new commit is pushed to a branch with running pipelines:Configuration
Enable auto-cancellation with annotation:running: Cancel only running pipelines on new commitspending: Cancel pending (queued) pipelines onlyall: Cancel both running and pending pipelines
Cleanup Flow
PAC automatically cleans up old PipelineRuns:Configuration
Global Setting (ConfigMap):Event Types and Triggers
Different events trigger different flows:- Pull Request
- Push
- Tag
- Incoming Webhook
Triggered On:Variables Available:
- Pull request opened
- New commits pushed to PR
- PR synchronized
pull_requestAnnotations:{{source_branch}}: PR source branch{{target_branch}}: PR target branch{{pull_request_number}}: PR number
Error Handling Flow
How PAC handles errors at different stages:Error Responses
PAC provides detailed error feedback:- Webhook validation failure: HTTP 401/403 response
- Repository not found: GitHub issue comment explaining setup
- Permission denied: Comment requesting
/ok-to-test - YAML syntax error: Comment with line number and error
- Task resolution failure: Comment with task name and resolver
- PipelineRun creation failure: Comment with Kubernetes error
Next Steps
Architecture
Understand the PAC architecture
Testing Guide
Learn how to test event flows
Development Setup
Set up your development environment
Contributing
Start contributing to PAC