- name
- GitHub Actions Integration for Agentic Workflows
- description
- Comprehensive guide to integrating agentic automation with GitHub Actions CI/CD pipelines, including workflow triggers, environment configuration, secrets management, matrix strategies, and deployment patterns for production-ready autonomous systems.
- license
- Apache-2.0
- version
- 2.0.0
- last_updated
- 2026-04-02
- tags
- ["github-actions","ci-cd","agentic-workflows","automation","deployment","matrix-strategy","secrets-management","workflow-triggers","environment-setup","production-deployment"]
# 🔄 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
```mermaid
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
1. **Workflow Triggers**: Event-driven agent execution
2. **Environment Configuration**: Runtime setup for agents
3. **Secrets Management**: Secure credential injection
4. **Matrix Strategies**: Parallel agent execution
5. **Deployment Automation**: Production rollout patterns
6. **Artifact Management**: Agent output handling
## 🚀 Workflow Trigger Patterns
### 1. Event-Driven Triggers
#### Pull Request Analysis
```yaml
# .github/workflows/agent-pr-analysis.yml
name: Agentic PR Analysis
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- develop
- 'feature/**'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
pr-analysis:
name: Analyze PR with Agent
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for comprehensive analysis
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '26'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Initialize MCP Gateway
run: |
npx @modelcontextprotocol/gateway start \
--config .github/copilot-mcp.json \
--port 3000 &
# Wait for gateway ready
timeout 30 bash -c 'until curl -f http://localhost:3000/health; do sleep 1; done'
- name: Run Agentic PR Analysis
id: agent-analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MCP_GATEWAY_URL: http://localhost:3000
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
node scripts/agents/pr-analyzer.js \
--pr-number="${PR_NUMBER}" \
--base-ref="${{ github.event.pull_request.base.ref }}" \
--head-ref="${{ github.event.pull_request.head.ref }}" \
--output=analysis.json
- name: Post Analysis Comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const analysis = JSON.parse(fs.readFileSync('analysis.json', 'utf8'));
const comment = `## 🤖 Agentic PR Analysis
**Complexity Score**: ${analysis.complexity}/10
**Security Issues**: ${analysis.security.issues.length}
**Test Coverage**: ${analysis.coverage.percentage}%
**Recommendation**: ${analysis.recommendation}
### 🔍 Key Findings
${analysis.findings.map(f => `- ${f}`).join('\n')}
### 🎯 Action Items
${analysis.actionItems.map(item => `- [ ] ${item}`).join('\n')}
---
*Analysis performed by GitHub Agentic Workflow*
`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
- name: Update PR Labels
if: success()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const analysis = JSON.parse(fs.readFileSync('analysis.json', 'utf8'));
const labels = [];
if (analysis.complexity >= 7) labels.push('complexity:high');
if (analysis.security.issues.length > 0) labels.push('security:review-needed');
if (analysis.coverage.percentage < 80) labels.push('test-coverage:low');
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
}
```
#### Issue Triage Agent
```yaml
# .github/workflows/agent-issue-triage.yml
name: Agentic Issue Triage
on:
issues:
types: [opened, edited, labeled]
issue_comment:
types: [created]
permissions:
issues: write
contents: read
jobs:
triage:
name: Intelligent Issue Triage
runs-on: ubuntu-latest
if: github.event_name == 'issues' || (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@agent'))
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install Agent Dependencies
run: |
pip install -r requirements/agent.txt
pip install mcp anthropic openai
- name: Run Triage Agent
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
run: |
python scripts/agents/issue_triage.py \
--issue-number="${ISSUE_NUMBER}" \
--action=classify
- name: Apply Triage Labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const triage = JSON.parse(fs.readFileSync('triage-result.json', 'utf8'));
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: triage.labels
});
if (triage.assignee) {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: [triage.assignee]
});
}
if (triage.priority === 'critical') {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '⚠️ **Critical Priority Detected** - This issue requires immediate attention.'
});
}
```
### 2. Scheduled Agent Execution
#### Nightly Intelligence Gathering
```yaml
# .github/workflows/agent-nightly-intelligence.yml
name: Nightly Intelligence Gathering
on:
schedule:
# Run every night at 02:00 UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger
inputs:
force_refresh:
description: 'Force refresh all data'
required: false
type: boolean
default: false
permissions:
contents: write
pull-requests: write
jobs:
intelligence:
name: Gather Intelligence Data
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '26'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Start MCP Servers
run: |
# Start Riksdag-Regering MCP server
npm run mcp:riksdag:start &
# Wait for server ready
sleep 10
- name: Run Intelligence Agent
id: intelligence
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MCP_RIKSDAG_URL: http://localhost:3001
FORCE_REFRESH: ${{ github.event.inputs.force_refresh || 'false' }}
run: |
node scripts/agents/intelligence-gatherer.js \
--mode=nightly \
--output-dir=cia-data \
--force-refresh="${FORCE_REFRESH}"
- name: Generate Intelligence Reports
run: |
node scripts/agents/report-generator.js \
--input-dir=cia-data \
--output-dir=news/intelligence \
--languages=en,sv,da,no,fi
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN }}
commit-message: |
feat: Nightly intelligence update $(date +%Y-%m-%d)
- Updated CIA intelligence data
- Generated intelligence reports
- Data freshness: < 24 hours
Co-authored-by: GitHub Actions <actions@github.com>
branch: intelligence/nightly-$(date +%Y%m%d)
delete-branch: true
title: '🔍 Nightly Intelligence Update - $(date +%Y-%m-%d)'
body: |
## 🤖 Automated Intelligence Update
This PR contains the nightly intelligence data refresh and report generation.
### 📊 Data Summary
- **Execution Time**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
- **Data Sources**: Riksdag API, CIA Intelligence Platform
- **Reports Generated**: ${{ env.REPORTS_COUNT }}
- **Languages**: English, Swedish, Danish, Norwegian, Finnish
### 🔍 Changes
- Updated `cia-data/` with latest intelligence exports
- Generated intelligence reports in `news/intelligence/`
- Validated data freshness (< 24 hours)
### ✅ Quality Checks
- [x] JSON schema validation
- [x] Data integrity checks
- [x] Report generation successful
- [x] Multi-language support verified
---
*Generated by GitHub Agentic Workflow*
labels: |
automated
intelligence
data-update
assignees: |
copilot
```
### 3. Manual Dispatch Workflows
#### Ad-Hoc Agent Tasks
```yaml
# .github/workflows/agent-manual-task.yml
name: Manual Agent Task
on:
workflow_dispatch:
inputs:
task_type:
description: 'Agent task type'
required: true
type: choice
options:
- code-review
- security-audit
- documentation-update
- data-refresh
- quality-check
target:
description: 'Target (PR number, file path, etc.)'
required: true
type: string
agent_model:
description: 'Agent model to use'
required: false
type: choice
options:
- claude-3-5-sonnet
- gpt-4-turbo
- gemini-pro
default: claude-3-5-sonnet
additional_instructions:
description: 'Additional instructions for agent'
required: false
type: string
permissions:
contents: write
pull-requests: write
issues: write
jobs:
execute-task:
name: Execute ${{ github.event.inputs.task_type }}
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Environment
uses: actions/setup-node@v4
with:
node-version: '26'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Execute Agent Task
id: agent-task
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TASK_TYPE: ${{ github.event.inputs.task_type }}
在 GitHub 查看