🔄 GitHub Actions Integration for Agentic Workflows
🔴 AI FIRST Quality Principle
Apply the AI FIRST principle: never accept first-pass quality. Minimum 2 iterations. Read all output, improve every section. No shortcuts.
📋 Overview
This skill provides comprehensive patterns for integrating GitHub Agentic Workflows with GitHub Actions CI/CD pipelines. It covers workflow orchestration, environment configuration, secrets management, parallel execution strategies, and deployment automation for production-ready autonomous agent systems.
🎯 Core Concepts
Agentic Workflow Integration Architecture
graph TB
subgraph "GitHub Events"
A[Push/PR/Issue] --> B[Workflow Trigger]
C[Schedule/Cron] --> B
D[Manual Dispatch] --> B
end
subgraph "GitHub Actions Runner"
B --> E[Environment Setup]
E --> F[Agent Initialization]
F --> G[MCP Server Start]
G --> H[Agentic Execution]
H --> I[Result Processing]
end
subgraph "Outputs"
I --> J[PR Creation]
I --> K[Issue Updates]
I --> L[Deployments]
I --> M[Artifacts]
end
style B fill:#00d9ff
style H fill:#ff006e
style I fill:#ffbe0b
Key Integration Points
Workflow Triggers: Event-driven agent execution
Environment Configuration: Runtime setup for agents
Secrets Management: Secure credential injection
Matrix Strategies: Parallel agent execution
Deployment Automation: Production rollout patterns
# .github/workflows/agent-nightly-intelligence.ymlname:NightlyIntelligenceGatheringon:schedule:# Run every night at 02:00 UTC-cron:'0 2 * * *'workflow_dispatch:# Allow manual triggerinputs:force_refresh:description:'Force refresh all data'required:falsetype:booleandefault:falsepermissions:contents:writepull-requests:writejobs:intelligence:name:GatherIntelligenceDataruns-on:ubuntu-latesttimeout-minutes:60steps:-name:HardenRunneruses:step-security/harden-runner@v2with:egress-policy:audit-name:CheckoutCodeuses:
[]
[]
[]
[]
# Combined environment for complex workflowssteps:-name:SetupNode.jsuses:actions/setup-node@v4with:node-version:'26'cache:'npm'-name:SetupPythonuses:actions/setup-python@v5with:python-version:'3.11'cache:'pip'-name:SetupGo(forMCPservers)uses:actions/setup-go@v5with:go-version:'1.21'cache:true-name:InstallAllDependenciesrun:|
# Node.js
npm ci
# Pythonpipinstall-rrequirements.txt# Go (if custom MCP servers)gomoddownload-
🔐 Secrets Management
1. GitHub Secrets Configuration
# Secrets usage in workflowsenv:# GitHub tokensGITHUB_TOKEN:${{secrets.GITHUB_TOKEN}}# Automatic tokenCOPILOT_PAT:${{secrets.COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN}}# Custom PAT# AI model API keysANTHROPIC_API_KEY:${{secrets.ANTHROPIC_API_KEY}}OPENAI_API_KEY:${{secrets.OPENAI_API_KEY}}# MCP server credentialsMCP_GITHUB_TOKEN:${{secrets.MCP_GITHUB_TOKEN}}MCP_DATABASE_URL:${{secrets.MCP_DATABASE_URL}}# Custom service credentialsCIA_API_KEY:${{secrets.CIA_API_KEY}}RIKSDAG_API_TOKEN:${{secrets.RIKSDAG_API_TOKEN}}
2. Environment-Specific Secrets
# Using GitHub Environments for different deployment stagesjobs:deploy-dev:name:DeploytoDevelopmentruns-on:ubuntu-latestenvironment:developmentsteps:-name:DeployAgentenv:API_KEY:${{secrets.DEV_API_KEY}}DATABASE_URL:${{secrets.DEV_DATABASE_URL}}run:|
./scripts/deploy-agent.sh --env=development
deploy-prod:name:DeploytoProductionruns-on:ubuntu-latestenvironment:productionneeds:deploy-devsteps:-name:DeployAgentenv:API_KEY:${{secrets.PROD_API_KEY}}DATABASE_URL:${{secrets.PROD_DATABASE_URL}}run:|
./scripts/deploy-agent.sh --env=production
3. Secret Rotation Pattern
# Automated secret rotation checkjobs:check-secrets:name:CheckSecretExpirationruns-on:ubuntu-lateststeps:-name:CheckTokenExpirationenv:GITHUB_TOKEN:${{secrets.GITHUB_TOKEN}}run:|
# Check PAT expiration
EXPIRATION=$(gh api user | jq -r '.token_expires_at // "never"')
if [ "$EXPIRATION"!="never" ];then# Capture each command substitution into its own variable first.# Avoids nested `$(…$(…)…)` shapes that the gh-aw AWF sandbox# rejects as a staged-injection pattern (see# `.github/prompts/01-bash-and-shell-safety.md`).EXP_EPOCH=$(date-d"$EXPIRATION"+%s)NOW_EPOCH=$(date+%s)DAYS_UNTIL_EXPIRATION=$(((EXP_EPOCH-NOW_EPOCH)/86400))if [ "$DAYS_UNTIL_EXPIRATION"-lt7 ] [ ]
[ ]
🔀 Matrix Strategy Patterns
1. Parallel Agent Execution
# Run multiple agents in parallel across different targetsjobs:analyze:name:Analyze${{matrix.component}}runs-on:ubuntu-latesttimeout-minutes:30strategy:matrix:component:-frontend-backend-api-database-infrastructureinclude:-component:frontendagent:ui-enhancement-specialistfiles:'src/frontend/**'-component:backendagent:security-architectfiles:'src/backend/**'-component:apiagent:api-integrationfiles:'src/api/**'-component:databaseagent:data-pipeline-specialist
[{ , }, { , }, { , }]
[
,
,
]
2. Multi-Language Agent Execution
# Run agents across multiple language versionsjobs:validate:name:Validate${{matrix.language}}Contentruns-on:ubuntu-lateststrategy:matrix:language: [en, sv, da, no, fi, de, fr, es, nl, ar, he, ja, ko, zh]
include:-language:enfile:index.htmlrtl:false-language:svfile:index_sv.htmlrtl:false-language:arfile:index_ar.htmlrtl:true-language:hefile:index_he.htmlrtl:
3. Multi-Platform Testing
# Test agents across different platformsjobs:test:name:Teston${{matrix.os}}runs-on:${{matrix.os}}strategy:matrix:os: [ubuntu-latest, windows-latest, macos-latest]
node-version: ['26']
fail-fast:falsesteps:-name:CheckoutCodeuses:actions/checkout@v4-name:SetupNode.jsuses:actions/setup-node@v4with:node-version:${{matrix.node-version}}-name:InstallDependenciesrun:npmci-name:RunAgentTestsrun:npm
🚀 Deployment Patterns
1. Agent Deployment Pipeline
# Complete deployment pipeline for agentic workflowsname:DeployAgenticWorkflowon:push:branches: [main]
paths:-'scripts/agents/**'-'.github/workflows/agent-*.yml'-'.github/copilot-mcp.json'permissions:contents:writedeployments:writepackages:writejobs:test:name:TestAgentsruns-on:ubuntu-lateststeps:-name:CheckoutCodeuses:actions/checkout@v4-name:SetupNode.jsuses:actions/setup-node@v4with:node-version:'26'cache:'npm'-name:InstallDependenciesrun:npmci
# Canary deployment with gradual traffic shiftjobs:deploy-canary:name:DeployCanary(10%)runs-on:ubuntu-latestenvironment:productionsteps:-name:DeployCanaryrun:|
kubectl apply -f k8s/agent-canary.yaml
-name:ConfigureTrafficSplit(10%)run:|
kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: agent
spec:
hosts:
- agent.example.com
http:
- match:
- headers:
user-agent:
regex: .*canary.*
route:
- destination:
host: agent-canary
weight: 100
- route:
- destination:
host: agent-stable
weight: 90
- destination:
host: agent-canary
weight: 10
EOF
-name:MonitorCanaryMetricsrun:|
# Monitor for 10 minutes
for i in {1..10}; do
ERROR_RATE=$(curl -s prometheus:9090/api/v1/query \
--data-urlencode 'query=rate(http_requests_total{service="agent-canary",status=~"5.."}[5m])' \
| jq -r '.data.result[0].value[1]')
if (( $(echo "$ERROR_RATE > 0.05" | bc -l) )); then
echo "❌ Error rate too high: $ERROR_RATE"
exit 1
fi
sleep 60
done
promote-canary:
🎯 Best Practices
1. Workflow Organization
# Use reusable workflows for common patterns# .github/workflows/reusable-agent-setup.ymlname:ReusableAgentSetupon:workflow_call:inputs:node-version:required:falsetype:stringdefault:'20'python-version:required:falsetype:stringdefault:'3.11'secrets:anthropic-key:required:falseopenai-key:required:falsejobs:setup:runs-on:ubuntu-lateststeps:-name:CheckoutCodeuses:actions/checkout@v4-name:SetupNode.jsuses:actions/setup-node@v4with:node-version:${{inputs.node-version}}cache:'npm'
[]
# Prevent concurrent workflow runsconcurrency:group:${{github.workflow}}-${{github.ref}}cancel-in-progress:true# Separate concurrency for different workflow typesconcurrency:group:agent-${{github.event_name}}-${{github.ref}}cancel-in-progress:${{github.event_name=='pull_request'}}
4. Timeout Management
# Set appropriate timeoutsjobs:quick-analysis:runs-on:ubuntu-latesttimeout-minutes:10# Quick tasksdeep-analysis:runs-on:ubuntu-latesttimeout-minutes:60# Longer tasksnightly-job:runs-on:ubuntu-latesttimeout-minutes:360# 6 hours for intensive tasks
🔒 Security Best Practices
1. Least Privilege Permissions
# Minimal permissionspermissions:contents:read# Only read access by default# Add specific permissions as neededpermissions:contents:readpull-requests:write# Only for PR commentsissues:write# Only for issue updates
🔗 Integration with Riksdagsmonitor agentic workflows
This gh-aw skill is applied by the 11 agentic news workflows in .github/workflows/news-*.md. Their domain contract (analysis-artifact product, gate, article contract) lives in: